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 /shell | |
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 'shell')
-rw-r--r-- | shell/hush.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/shell/hush.c b/shell/hush.c index 8afa15e89..4d4843173 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -709,28 +709,34 @@ static void signal_SA_RESTART(int sig, void (*handler)(int)) | |||
709 | /* Signals are grouped, we handle them in batches */ | 709 | /* Signals are grouped, we handle them in batches */ |
710 | static void set_fatal_sighandler(void (*handler)(int)) | 710 | static void set_fatal_sighandler(void (*handler)(int)) |
711 | { | 711 | { |
712 | signal(SIGILL , handler); | 712 | bb_signals(0 |
713 | signal(SIGTRAP, handler); | 713 | + (1 << SIGILL) |
714 | signal(SIGABRT, handler); | 714 | + (1 << SIGTRAP) |
715 | signal(SIGFPE , handler); | 715 | + (1 << SIGABRT) |
716 | signal(SIGBUS , handler); | 716 | + (1 << SIGFPE) |
717 | signal(SIGSEGV, handler); | 717 | + (1 << SIGBUS) |
718 | + (1 << SIGSEGV) | ||
718 | /* bash 3.2 seems to handle these just like 'fatal' ones */ | 719 | /* bash 3.2 seems to handle these just like 'fatal' ones */ |
719 | signal(SIGHUP , handler); | 720 | + (1 << SIGHUP) |
720 | signal(SIGPIPE, handler); | 721 | + (1 << SIGPIPE) |
721 | signal(SIGALRM, handler); | 722 | + (1 << SIGALRM) |
723 | , handler); | ||
722 | } | 724 | } |
723 | static void set_jobctrl_sighandler(void (*handler)(int)) | 725 | static void set_jobctrl_sighandler(void (*handler)(int)) |
724 | { | 726 | { |
725 | signal(SIGTSTP, handler); | 727 | bb_signals(0 |
726 | signal(SIGTTIN, handler); | 728 | + (1 << SIGTSTP) |
727 | signal(SIGTTOU, handler); | 729 | + (1 << SIGTTIN) |
730 | + (1 << SIGTTOU) | ||
731 | , handler); | ||
728 | } | 732 | } |
729 | static void set_misc_sighandler(void (*handler)(int)) | 733 | static void set_misc_sighandler(void (*handler)(int)) |
730 | { | 734 | { |
731 | signal(SIGINT , handler); | 735 | bb_signals(0 |
732 | signal(SIGQUIT, handler); | 736 | + (1 << SIGINT) |
733 | signal(SIGTERM, handler); | 737 | + (1 << SIGQUIT) |
738 | + (1 << SIGTERM) | ||
739 | , handler); | ||
734 | } | 740 | } |
735 | /* SIGCHLD is special and handled separately */ | 741 | /* SIGCHLD is special and handled separately */ |
736 | 742 | ||