systemctl: do not fall back to StartUnit automatically for sleep operations

In the majority of cases, this is caused by
sleep_supported() returning error. Hence it's
very likely that it would fail again, so
the fallback is not really useful. Instead,
honor the --force option for these verbs.
This commit is contained in:
Mike Yuan
2024-05-08 13:45:49 +08:00
parent 3fce141c1b
commit 4f344de792
2 changed files with 36 additions and 20 deletions
+4 -1
View File
@@ -223,8 +223,11 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
case ACTION_HYBRID_SLEEP:
case ACTION_SUSPEND_THEN_HIBERNATE:
/* For sleep operations, do not automatically fall back to low-level operation for
* errors other than logind not available. There's a high chance that logind did
* some extra sanity check and that didn't pass. */
r = logind_reboot(a);
if (r >= 0 || IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
if (r >= 0 || (r != -ENOSYS && arg_force == 0))
return r;
arg_no_block = true;