diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-03-02 17:39:13 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-03-02 17:39:13 +0100 |
commit | 7db2a7c20e8d48ad9cce934c9a6d2ee563d32c84 (patch) | |
tree | ede92e1c743f8dbc392da06e2bf0117c07676f06 | |
parent | dac8d80f77af617effadc50f6be47768685d81b0 (diff) | |
download | busybox-7db2a7c20e8d48ad9cce934c9a6d2ee563d32c84.tar.gz |
runsvdir: if pid==1, also intercept SIGINT for -s SCRIPT
function old new delta
runsvdir_main 1057 1064 +7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | runit/runsvdir.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index a08af3bae..b4c0b2ef0 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c @@ -222,6 +222,7 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv) unsigned stampcheck; int i; int need_rescan; + bool i_am_init; char *opt_s_argv[3]; INIT_G(); @@ -232,18 +233,21 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv) getopt32(argv, "Ps:", &opt_s_argv[0]); argv += optind; + i_am_init = (getpid() == 1); bb_signals(0 | (1 << SIGTERM) | (1 << SIGHUP) /* For busybox's init, SIGTERM == reboot, - * SIGUSR1 == halt - * SIGUSR2 == poweroff - * so we need to intercept SIGUSRn too. + * SIGUSR1 == halt, + * SIGUSR2 == poweroff, + * Ctlr-ALt-Del sends SIGINT to init, + * so we need to intercept SIGUSRn and SIGINT too. * Note that we do not implement actual reboot * (killall(TERM) + umount, etc), we just pause * respawing and avoid exiting (-> making kernel oops). - * The user is responsible for the rest. */ - | (getpid() == 1 ? ((1 << SIGUSR1) | (1 << SIGUSR2)) : 0) + * The user is responsible for the rest. + */ + | (i_am_init ? ((1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGINT)) : 0) , record_signo); svdir = *argv++; @@ -394,7 +398,7 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv) } /* SIGHUP or SIGTERM (or SIGUSRn if we are init) */ /* Exit unless we are init */ - if (getpid() != 1) + if (!i_am_init) return (SIGHUP == sig) ? 111 : EXIT_SUCCESS; /* init continues to monitor services forever */ |