systemctl: make sure "reboot", "suspend" and friends are always asynchronous

Currently, "systemctl reboot" behaves differently in setups with and
without logind. If logind is used (which is probably the more common
case) the operation is asynchronous, and otherwise synchronous (though
subject to --no-block in this case). Let's clean this up, and always
expose the same behaviour, regardless if logind is used or not: let's
always make it asynchronous.

It might make sense to add a "--block" mode in a future PR that makes
these operations synchronous, but this requires non-trivial work in
logind, and is outside of the scope of this change.

See: #6479
This commit is contained in:
Lennart Poettering 2017-09-29 16:07:11 +02:00
parent 36b69c3131
commit 130246d2e8
1 changed files with 10 additions and 2 deletions

View File

@ -3585,8 +3585,16 @@ static int start_special(int argc, char *argv[], void *userdata) {
/* requested operation is not supported or already in progress */
return r;
/* On all other errors, try low-level operation */
}
/* On all other errors, try low-level operation. In order to minimize the difference between
* operation with and without logind, we explicitly enable non-blocking mode for this, as
* logind's shutdown operations are always non-blocking. */
arg_no_block = true;
} else if (IN_SET(a, ACTION_EXIT, ACTION_KEXEC))
/* Since exit/kexec are so close in behaviour to power-off/reboot, let's also make them
* asynchronous, in order to not confuse the user needlessly with unexpected behaviour. */
arg_no_block = true;
r = start_unit(argc, argv, userdata);
}