aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-09 00:15:11 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-09 00:15:11 +0000
commit3fa36e235021af5810333a52876d29efc661ad60 (patch)
tree71249d42a3a17ebf3c166826b71fe1453dcb6756
parent73cc54388daeae391698b8afe788f421cf9e394d (diff)
downloadbusybox-3fa36e235021af5810333a52876d29efc661ad60.tar.gz
*: 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.c16
-rw-r--r--loginutils/login.c4
-rw-r--r--loginutils/sulogin.c5
-rw-r--r--networking/nc.c3
-rw-r--r--networking/tcpudp.c6
-rw-r--r--runit/runsv.c5
-rw-r--r--runit/svlogd.c5
-rw-r--r--util-linux/script.c3
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 {
static struct init_action *init_action_list = NULL;
static const char *log_console = VC_5;
-static sig_atomic_t got_cont = 0;
enum {
L_LOG = 0x1,
@@ -613,24 +612,21 @@ static void ctrlaltdel_signal(int sig UNUSED_PARAM)
run_actions(CTRLALTDEL);
}
+/* The SIGCONT handler is set to record_signo().
+ * It just sets bb_got_signal = SIGCONT. */
+
/* The SIGSTOP & SIGTSTP handler */
static void stop_handler(int sig UNUSED_PARAM)
{
int saved_errno = errno;
- got_cont = 0;
- while (!got_cont)
+ bb_got_signal = 0;
+ while (bb_got_signal == 0)
pause();
errno = saved_errno;
}
-/* The SIGCONT handler */
-static void cont_handler(int sig UNUSED_PARAM)
-{
- got_cont = 1;
-}
-
static void new_init_action(uint8_t action_type, const char *command, const char *cons)
{
struct init_action *a, *last;
@@ -808,7 +804,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
+ (1 << SIGTERM) /* reboot */
, halt_reboot_pwoff);
signal(SIGINT, ctrlaltdel_signal);
- signal(SIGCONT, cont_handler);
+ signal(SIGCONT, record_signo);
bb_signals(0
+ (1 << SIGSTOP)
+ (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)
// If this stuff is really needed, add it and explain why!
/* Set signals to defaults */
- /*signal(SIGALRM, SIG_DFL); - not needed, we already set it
- * to non-SIG_IGN, and on exec such signals are reset to SIG_DFL */
+ /* Non-ignored signals revert to SIG_DFL on exec anyway */
+ /*signal(SIGALRM, SIG_DFL);*/
/* Is this correct? This way user can ctrl-c out of /etc/profile,
* 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)
opt_complementary = "t+"; /* -t N */
getopt32(argv, "t:", &timeout);
+ argv += optind;
- if (argv[optind]) {
+ if (argv[0]) {
close(0);
close(1);
- dup(xopen(argv[optind], O_RDWR));
+ dup(xopen(argv[0], O_RDWR));
close(2);
dup(0);
}
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)
if (wsecs) {
alarm(0);
- signal(SIGALRM, SIG_DFL);
+ /* Non-ignored siganls revert to SIG_DFL on exec anyway */
+ /*signal(SIGALRM, SIG_DFL);*/
}
/* -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)
xdup2(0, 1);
- signal(SIGTERM, SIG_DFL);
- signal(SIGPIPE, SIG_DFL);
- signal(SIGCHLD, SIG_DFL);
+ signal(SIGPIPE, SIG_DFL); /* this one was SIG_IGNed */
+ /* Non-ignored signals revert to SIG_DFL on exec anyway */
+ /*signal(SIGCHLD, SIG_DFL);*/
sig_unblock(SIGCHLD);
#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)
xdup2(logpipe.wr, 1);
}
}
- bb_signals(0
+ /* Non-ignored signals revert to SIG_DFL on exec anyway */
+ /*bb_signals(0
+ (1 << SIGCHLD)
+ (1 << SIGTERM)
- , SIG_DFL);
+ , SIG_DFL);*/
sig_unblock(SIGCHLD);
sig_unblock(SIGTERM);
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)
int fd;
/* child */
- bb_signals(0
+ /* Non-ignored signals revert to SIG_DFL on exec anyway */
+ /*bb_signals(0
+ (1 << SIGTERM)
+ (1 << SIGALRM)
+ (1 << SIGHUP)
- , SIG_DFL);
+ , SIG_DFL);*/
sig_unblock(SIGTERM);
sig_unblock(SIGALRM);
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)
setsid();
ioctl(0, TIOCSCTTY, 0 /* 0: don't forcibly steal */);
- /* signal(SIGCHLD, SIG_DFL); - exec does this for us */
+ /* Non-ignored signals revert to SIG_DFL on exec anyway */
+ /*signal(SIGCHLD, SIG_DFL);*/
execl(shell, shell, shell_opt, shell_arg, NULL);
bb_simple_perror_msg_and_die(shell);
}