diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-09 00:15:11 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-09 00:15:11 +0000 |
commit | 3fa36e235021af5810333a52876d29efc661ad60 (patch) | |
tree | 71249d42a3a17ebf3c166826b71fe1453dcb6756 | |
parent | 73cc54388daeae391698b8afe788f421cf9e394d (diff) | |
download | busybox-w32-3fa36e235021af5810333a52876d29efc661ad60.tar.gz busybox-w32-3fa36e235021af5810333a52876d29efc661ad60.tar.bz2 busybox-w32-3fa36e235021af5810333a52876d29efc661ad60.zip |
*: a bit of code shrink
function old new delta
stop_handler 41 38 -3
sulogin_main 508 504 -4
got_cont 4 - -4
cont_handler 11 - -11
startservice 309 297 -12
processorstart 423 409 -14
tcpudpsvd_main 1861 1843 -18
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/5 up/down: 0/-66) Total: -66 bytes
-rw-r--r-- | init/init.c | 16 | ||||
-rw-r--r-- | loginutils/login.c | 4 | ||||
-rw-r--r-- | loginutils/sulogin.c | 5 | ||||
-rw-r--r-- | networking/nc.c | 3 | ||||
-rw-r--r-- | networking/tcpudp.c | 6 | ||||
-rw-r--r-- | runit/runsv.c | 5 | ||||
-rw-r--r-- | runit/svlogd.c | 5 | ||||
-rw-r--r-- | util-linux/script.c | 3 |
8 files changed, 24 insertions, 23 deletions
diff --git a/init/init.c b/init/init.c index 3d171d71f..ef387819c 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -60,7 +60,6 @@ struct init_action { | |||
60 | static struct init_action *init_action_list = NULL; | 60 | static struct init_action *init_action_list = NULL; |
61 | 61 | ||
62 | static const char *log_console = VC_5; | 62 | static const char *log_console = VC_5; |
63 | static sig_atomic_t got_cont = 0; | ||
64 | 63 | ||
65 | enum { | 64 | enum { |
66 | L_LOG = 0x1, | 65 | L_LOG = 0x1, |
@@ -613,24 +612,21 @@ static void ctrlaltdel_signal(int sig UNUSED_PARAM) | |||
613 | run_actions(CTRLALTDEL); | 612 | run_actions(CTRLALTDEL); |
614 | } | 613 | } |
615 | 614 | ||
615 | /* The SIGCONT handler is set to record_signo(). | ||
616 | * It just sets bb_got_signal = SIGCONT. */ | ||
617 | |||
616 | /* The SIGSTOP & SIGTSTP handler */ | 618 | /* The SIGSTOP & SIGTSTP handler */ |
617 | static void stop_handler(int sig UNUSED_PARAM) | 619 | static void stop_handler(int sig UNUSED_PARAM) |
618 | { | 620 | { |
619 | int saved_errno = errno; | 621 | int saved_errno = errno; |
620 | 622 | ||
621 | got_cont = 0; | 623 | bb_got_signal = 0; |
622 | while (!got_cont) | 624 | while (bb_got_signal == 0) |
623 | pause(); | 625 | pause(); |
624 | 626 | ||
625 | errno = saved_errno; | 627 | errno = saved_errno; |
626 | } | 628 | } |
627 | 629 | ||
628 | /* The SIGCONT handler */ | ||
629 | static void cont_handler(int sig UNUSED_PARAM) | ||
630 | { | ||
631 | got_cont = 1; | ||
632 | } | ||
633 | |||
634 | static void new_init_action(uint8_t action_type, const char *command, const char *cons) | 630 | static void new_init_action(uint8_t action_type, const char *command, const char *cons) |
635 | { | 631 | { |
636 | struct init_action *a, *last; | 632 | struct init_action *a, *last; |
@@ -808,7 +804,7 @@ int init_main(int argc UNUSED_PARAM, char **argv) | |||
808 | + (1 << SIGTERM) /* reboot */ | 804 | + (1 << SIGTERM) /* reboot */ |
809 | , halt_reboot_pwoff); | 805 | , halt_reboot_pwoff); |
810 | signal(SIGINT, ctrlaltdel_signal); | 806 | signal(SIGINT, ctrlaltdel_signal); |
811 | signal(SIGCONT, cont_handler); | 807 | signal(SIGCONT, record_signo); |
812 | bb_signals(0 | 808 | bb_signals(0 |
813 | + (1 << SIGSTOP) | 809 | + (1 << SIGSTOP) |
814 | + (1 << SIGTSTP) | 810 | + (1 << SIGTSTP) |
diff --git a/loginutils/login.c b/loginutils/login.c index 70e3b1333..a18b4d5d7 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -486,8 +486,8 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
486 | // If this stuff is really needed, add it and explain why! | 486 | // If this stuff is really needed, add it and explain why! |
487 | 487 | ||
488 | /* Set signals to defaults */ | 488 | /* Set signals to defaults */ |
489 | /*signal(SIGALRM, SIG_DFL); - not needed, we already set it | 489 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ |
490 | * to non-SIG_IGN, and on exec such signals are reset to SIG_DFL */ | 490 | /*signal(SIGALRM, SIG_DFL);*/ |
491 | 491 | ||
492 | /* Is this correct? This way user can ctrl-c out of /etc/profile, | 492 | /* Is this correct? This way user can ctrl-c out of /etc/profile, |
493 | * potentially creating security breach (tested with bash 3.0). | 493 | * potentially creating security breach (tested with bash 3.0). |
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index bfd42569a..892c43484 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -32,11 +32,12 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
32 | 32 | ||
33 | opt_complementary = "t+"; /* -t N */ | 33 | opt_complementary = "t+"; /* -t N */ |
34 | getopt32(argv, "t:", &timeout); | 34 | getopt32(argv, "t:", &timeout); |
35 | argv += optind; | ||
35 | 36 | ||
36 | if (argv[optind]) { | 37 | if (argv[0]) { |
37 | close(0); | 38 | close(0); |
38 | close(1); | 39 | close(1); |
39 | dup(xopen(argv[optind], O_RDWR)); | 40 | dup(xopen(argv[0], O_RDWR)); |
40 | close(2); | 41 | close(2); |
41 | dup(0); | 42 | dup(0); |
42 | } | 43 | } |
diff --git a/networking/nc.c b/networking/nc.c index 1a99f91cc..fe845f582 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -131,7 +131,8 @@ int nc_main(int argc, char **argv) | |||
131 | 131 | ||
132 | if (wsecs) { | 132 | if (wsecs) { |
133 | alarm(0); | 133 | alarm(0); |
134 | signal(SIGALRM, SIG_DFL); | 134 | /* Non-ignored siganls revert to SIG_DFL on exec anyway */ |
135 | /*signal(SIGALRM, SIG_DFL);*/ | ||
135 | } | 136 | } |
136 | 137 | ||
137 | /* -e given? */ | 138 | /* -e given? */ |
diff --git a/networking/tcpudp.c b/networking/tcpudp.c index 0d8217e02..3b73f213f 100644 --- a/networking/tcpudp.c +++ b/networking/tcpudp.c | |||
@@ -497,9 +497,9 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv) | |||
497 | 497 | ||
498 | xdup2(0, 1); | 498 | xdup2(0, 1); |
499 | 499 | ||
500 | signal(SIGTERM, SIG_DFL); | 500 | signal(SIGPIPE, SIG_DFL); /* this one was SIG_IGNed */ |
501 | signal(SIGPIPE, SIG_DFL); | 501 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ |
502 | signal(SIGCHLD, SIG_DFL); | 502 | /*signal(SIGCHLD, SIG_DFL);*/ |
503 | sig_unblock(SIGCHLD); | 503 | sig_unblock(SIGCHLD); |
504 | 504 | ||
505 | #ifdef SSLSVD | 505 | #ifdef SSLSVD |
diff --git a/runit/runsv.c b/runit/runsv.c index 56244d03f..123720864 100644 --- a/runit/runsv.c +++ b/runit/runsv.c | |||
@@ -336,10 +336,11 @@ static void startservice(struct svdir *s) | |||
336 | xdup2(logpipe.wr, 1); | 336 | xdup2(logpipe.wr, 1); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | bb_signals(0 | 339 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ |
340 | /*bb_signals(0 | ||
340 | + (1 << SIGCHLD) | 341 | + (1 << SIGCHLD) |
341 | + (1 << SIGTERM) | 342 | + (1 << SIGTERM) |
342 | , SIG_DFL); | 343 | , SIG_DFL);*/ |
343 | sig_unblock(SIGCHLD); | 344 | sig_unblock(SIGCHLD); |
344 | sig_unblock(SIGTERM); | 345 | sig_unblock(SIGTERM); |
345 | execvp(*run, run); | 346 | execvp(*run, run); |
diff --git a/runit/svlogd.c b/runit/svlogd.c index 64191281e..9beb9f53f 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -227,11 +227,12 @@ static void processorstart(struct logdir *ld) | |||
227 | int fd; | 227 | int fd; |
228 | 228 | ||
229 | /* child */ | 229 | /* child */ |
230 | bb_signals(0 | 230 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ |
231 | /*bb_signals(0 | ||
231 | + (1 << SIGTERM) | 232 | + (1 << SIGTERM) |
232 | + (1 << SIGALRM) | 233 | + (1 << SIGALRM) |
233 | + (1 << SIGHUP) | 234 | + (1 << SIGHUP) |
234 | , SIG_DFL); | 235 | , SIG_DFL);*/ |
235 | sig_unblock(SIGTERM); | 236 | sig_unblock(SIGTERM); |
236 | sig_unblock(SIGALRM); | 237 | sig_unblock(SIGALRM); |
237 | sig_unblock(SIGHUP); | 238 | sig_unblock(SIGHUP); |
diff --git a/util-linux/script.c b/util-linux/script.c index 39ec546a7..2e103fd0f 100644 --- a/util-linux/script.c +++ b/util-linux/script.c | |||
@@ -179,7 +179,8 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
179 | setsid(); | 179 | setsid(); |
180 | ioctl(0, TIOCSCTTY, 0 /* 0: don't forcibly steal */); | 180 | ioctl(0, TIOCSCTTY, 0 /* 0: don't forcibly steal */); |
181 | 181 | ||
182 | /* signal(SIGCHLD, SIG_DFL); - exec does this for us */ | 182 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ |
183 | /*signal(SIGCHLD, SIG_DFL);*/ | ||
183 | execl(shell, shell, shell_opt, shell_arg, NULL); | 184 | execl(shell, shell, shell_opt, shell_arg, NULL); |
184 | bb_simple_perror_msg_and_die(shell); | 185 | bb_simple_perror_msg_and_die(shell); |
185 | } | 186 | } |