]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemd-inhibit: ignore signal interrupt from keyboard (#8569)
authorChristian Hesse <mail@eworm.de>
Wed, 28 Mar 2018 19:58:10 +0000 (21:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 28 Mar 2018 19:58:10 +0000 (21:58 +0200)
By default both processes, systemd-inhibit and the forked one, receive
the signals. Pressing Ctrl+C on the keyboard results in SIGINT being
sent to the processes, followed by SIGTERM being sent to the forked
process when systemd-inhibit exits. This can cause trouble when the
forked process does not clean up properly but exit immediately.

Instead make systemd-inhibit ignore SIGINT, leaving it to the forked
process to clean up and exit.

src/login/inhibit.c

index 6b5d9c29b96d4f4847146eadec366a81800edbf4..c118421e6baaac623339758746b2c1d385c9f44f 100644 (file)
@@ -254,6 +254,9 @@ int main(int argc, char *argv[]) {
                 _cleanup_free_ char *w = NULL;
                 pid_t pid;
 
+                /* Ignore SIGINT and allow the forked process to receive it */
+                (void) ignore_signals(SIGINT, -1);
+
                 if (!arg_who)
                         arg_who = w = strv_join(argv + optind, " ");