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-w32-7db2a7c20e8d48ad9cce934c9a6d2ee563d32c84.tar.gz busybox-w32-7db2a7c20e8d48ad9cce934c9a6d2ee563d32c84.tar.bz2 busybox-w32-7db2a7c20e8d48ad9cce934c9a6d2ee563d32c84.zip |
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) | |||
222 | unsigned stampcheck; | 222 | unsigned stampcheck; |
223 | int i; | 223 | int i; |
224 | int need_rescan; | 224 | int need_rescan; |
225 | bool i_am_init; | ||
225 | char *opt_s_argv[3]; | 226 | char *opt_s_argv[3]; |
226 | 227 | ||
227 | INIT_G(); | 228 | INIT_G(); |
@@ -232,18 +233,21 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv) | |||
232 | getopt32(argv, "Ps:", &opt_s_argv[0]); | 233 | getopt32(argv, "Ps:", &opt_s_argv[0]); |
233 | argv += optind; | 234 | argv += optind; |
234 | 235 | ||
236 | i_am_init = (getpid() == 1); | ||
235 | bb_signals(0 | 237 | bb_signals(0 |
236 | | (1 << SIGTERM) | 238 | | (1 << SIGTERM) |
237 | | (1 << SIGHUP) | 239 | | (1 << SIGHUP) |
238 | /* For busybox's init, SIGTERM == reboot, | 240 | /* For busybox's init, SIGTERM == reboot, |
239 | * SIGUSR1 == halt | 241 | * SIGUSR1 == halt, |
240 | * SIGUSR2 == poweroff | 242 | * SIGUSR2 == poweroff, |
241 | * so we need to intercept SIGUSRn too. | 243 | * Ctlr-ALt-Del sends SIGINT to init, |
244 | * so we need to intercept SIGUSRn and SIGINT too. | ||
242 | * Note that we do not implement actual reboot | 245 | * Note that we do not implement actual reboot |
243 | * (killall(TERM) + umount, etc), we just pause | 246 | * (killall(TERM) + umount, etc), we just pause |
244 | * respawing and avoid exiting (-> making kernel oops). | 247 | * respawing and avoid exiting (-> making kernel oops). |
245 | * The user is responsible for the rest. */ | 248 | * The user is responsible for the rest. |
246 | | (getpid() == 1 ? ((1 << SIGUSR1) | (1 << SIGUSR2)) : 0) | 249 | */ |
250 | | (i_am_init ? ((1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGINT)) : 0) | ||
247 | , record_signo); | 251 | , record_signo); |
248 | svdir = *argv++; | 252 | svdir = *argv++; |
249 | 253 | ||
@@ -394,7 +398,7 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv) | |||
394 | } | 398 | } |
395 | /* SIGHUP or SIGTERM (or SIGUSRn if we are init) */ | 399 | /* SIGHUP or SIGTERM (or SIGUSRn if we are init) */ |
396 | /* Exit unless we are init */ | 400 | /* Exit unless we are init */ |
397 | if (getpid() != 1) | 401 | if (!i_am_init) |
398 | return (SIGHUP == sig) ? 111 : EXIT_SUCCESS; | 402 | return (SIGHUP == sig) ? 111 : EXIT_SUCCESS; |
399 | 403 | ||
400 | /* init continues to monitor services forever */ | 404 | /* init continues to monitor services forever */ |