From: Lennart Poettering Date: Fri, 29 Sep 2017 14:07:11 +0000 (+0200) Subject: systemctl: make sure "reboot", "suspend" and friends are always asynchronous X-Git-Tag: v235~18^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=130246d2e8d7a0c91dbaa1110fa7a6d6e6f86a50;p=thirdparty%2Fsystemd.git 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 --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 2a385bf3503..dd0ebff1793 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -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); }