diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-16 22:58:56 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-16 22:58:56 +0000 |
| commit | 25591c322c9305bd54d3ab80cfaf01ef87640d77 (patch) | |
| tree | 66ce77758e35f4faa2d5f611d0535365f2cba00a /init | |
| parent | 7fc294cdfe1e7f4a12c44f984a698b0c0f609075 (diff) | |
| download | busybox-w32-25591c322c9305bd54d3ab80cfaf01ef87640d77.tar.gz busybox-w32-25591c322c9305bd54d3ab80cfaf01ef87640d77.tar.bz2 busybox-w32-25591c322c9305bd54d3ab80cfaf01ef87640d77.zip | |
libbb: introduce bb_signals and bb_signals_recursive,
which sets same handler for many signals. sig_catch is nuked
(bb_signals_recursive is more descriptive name).
*: use them as appropriate.
function old new delta
bb_signals_recursive - 95 +95
bb_signals - 52 +52
run_command 258 273 +15
svlogd_main 1368 1377 +9
runsv_main 1746 1752 +6
runsvdir_main 1643 1646 +3
UNSPEC_print 64 66 +2
time_main 1128 1127 -1
...
resize_main 246 210 -36
sig_catch 63 - -63
set_fatal_sighandler 85 14 -71
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 5/24 up/down: 182/-548) Total: -366 bytes
Diffstat (limited to 'init')
| -rw-r--r-- | init/init.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/init/init.c b/init/init.c index 9e24817b7..080c5b3af 100644 --- a/init/init.c +++ b/init/init.c | |||
| @@ -319,15 +319,17 @@ static pid_t run(const struct init_action *a) | |||
| 319 | /* Child */ | 319 | /* Child */ |
| 320 | 320 | ||
| 321 | /* Reset signal handlers that were set by the parent process */ | 321 | /* Reset signal handlers that were set by the parent process */ |
| 322 | signal(SIGUSR1, SIG_DFL); | 322 | bb_signals(0 |
| 323 | signal(SIGUSR2, SIG_DFL); | 323 | + (1 << SIGUSR1) |
| 324 | signal(SIGINT, SIG_DFL); | 324 | + (1 << SIGUSR2) |
| 325 | signal(SIGTERM, SIG_DFL); | 325 | + (1 << SIGINT) |
| 326 | signal(SIGHUP, SIG_DFL); | 326 | + (1 << SIGTERM) |
| 327 | signal(SIGQUIT, SIG_DFL); | 327 | + (1 << SIGHUP) |
| 328 | signal(SIGCONT, SIG_DFL); | 328 | + (1 << SIGQUIT) |
| 329 | signal(SIGSTOP, SIG_DFL); | 329 | + (1 << SIGCONT) |
| 330 | signal(SIGTSTP, SIG_DFL); | 330 | + (1 << SIGSTOP) |
| 331 | + (1 << SIGTSTP) | ||
| 332 | , SIG_DFL); | ||
| 331 | 333 | ||
| 332 | /* Create a new session and make ourself the process | 334 | /* Create a new session and make ourself the process |
| 333 | * group leader */ | 335 | * group leader */ |
| @@ -349,9 +351,11 @@ static pid_t run(const struct init_action *a) | |||
| 349 | 351 | ||
| 350 | if (pid > 0) { | 352 | if (pid > 0) { |
| 351 | /* Parent - wait till the child is done */ | 353 | /* Parent - wait till the child is done */ |
| 352 | signal(SIGINT, SIG_IGN); | 354 | bb_signals(0 |
| 353 | signal(SIGTSTP, SIG_IGN); | 355 | + (1 << SIGINT) |
| 354 | signal(SIGQUIT, SIG_IGN); | 356 | + (1 << SIGTSTP) |
| 357 | + (1 << SIGQUIT) | ||
| 358 | , SIG_IGN); | ||
| 355 | signal(SIGCHLD, SIG_DFL); | 359 | signal(SIGCHLD, SIG_DFL); |
| 356 | 360 | ||
| 357 | waitfor(pid); | 361 | waitfor(pid); |
| @@ -864,15 +868,21 @@ int init_main(int argc, char **argv) | |||
| 864 | } | 868 | } |
| 865 | /* Set up sig handlers -- be sure to | 869 | /* Set up sig handlers -- be sure to |
| 866 | * clear all of these in run() */ | 870 | * clear all of these in run() */ |
| 867 | signal(SIGHUP, exec_restart_action); | 871 | bb_signals(0 |
| 868 | signal(SIGQUIT, exec_restart_action); | 872 | + (1 << SIGHUP) |
| 869 | signal(SIGUSR1, halt_reboot_pwoff); /* halt */ | 873 | + (1 << SIGQUIT) |
| 870 | signal(SIGUSR2, halt_reboot_pwoff); /* poweroff */ | 874 | , exec_restart_action); |
| 871 | signal(SIGTERM, halt_reboot_pwoff); /* reboot */ | 875 | bb_signals(0 |
| 876 | + (1 << SIGUSR1) /* halt */ | ||
| 877 | + (1 << SIGUSR2) /* poweroff */ | ||
| 878 | + (1 << SIGTERM) /* reboot */ | ||
| 879 | , halt_reboot_pwoff); | ||
| 872 | signal(SIGINT, ctrlaltdel_signal); | 880 | signal(SIGINT, ctrlaltdel_signal); |
| 873 | signal(SIGCONT, cont_handler); | 881 | signal(SIGCONT, cont_handler); |
| 874 | signal(SIGSTOP, stop_handler); | 882 | bb_signals(0 |
| 875 | signal(SIGTSTP, stop_handler); | 883 | + (1 << SIGSTOP) |
| 884 | + (1 << SIGTSTP) | ||
| 885 | , stop_handler); | ||
| 876 | 886 | ||
| 877 | /* Turn off rebooting via CTL-ALT-DEL -- we get a | 887 | /* Turn off rebooting via CTL-ALT-DEL -- we get a |
| 878 | * SIGINT on CAD so we can shut things down gracefully... */ | 888 | * SIGINT on CAD so we can shut things down gracefully... */ |
