diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-26 12:29:59 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-26 12:29:59 +0000 |
commit | f09f4e015bffe6db5d7e63d47b23f22db4806736 (patch) | |
tree | 38393e9a60430aa64541370c68151101e62a64ec | |
parent | 48637e0924dcd13629ebf3aeffa80cdda1beb5af (diff) | |
download | busybox-w32-f09f4e015bffe6db5d7e63d47b23f22db4806736.tar.gz busybox-w32-f09f4e015bffe6db5d7e63d47b23f22db4806736.tar.bz2 busybox-w32-f09f4e015bffe6db5d7e63d47b23f22db4806736.zip |
runsv: small optimization
*: more paranoia around passing NULL to execl[e]
function old new delta
custom 240 221 -19
-rw-r--r-- | miscutils/crond.c | 4 | ||||
-rw-r--r-- | networking/ifupdown.c | 2 | ||||
-rw-r--r-- | runit/runsv.c | 7 | ||||
-rw-r--r-- | runit/runsvdir.c | 2 | ||||
-rw-r--r-- | util-linux/script.c | 2 |
5 files changed, 7 insertions, 10 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index b2fedb152..767aa120a 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
@@ -775,7 +775,7 @@ ForkJob(const char *user, CronLine *line, int mailFd, | |||
775 | } | 775 | } |
776 | /* crond 3.0pl1-100 puts tasks in separate process groups */ | 776 | /* crond 3.0pl1-100 puts tasks in separate process groups */ |
777 | bb_setpgrp(); | 777 | bb_setpgrp(); |
778 | execlp(prog, prog, cmd, arg, NULL); | 778 | execlp(prog, prog, cmd, arg, (char *) NULL); |
779 | crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg); | 779 | crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg); |
780 | if (mail_filename) { | 780 | if (mail_filename) { |
781 | fdprintf(1, "Exec failed: %s -c %s\n", prog, arg); | 781 | fdprintf(1, "Exec failed: %s -c %s\n", prog, arg); |
@@ -912,7 +912,7 @@ static void RunJob(const char *user, CronLine *line) | |||
912 | } | 912 | } |
913 | /* crond 3.0pl1-100 puts tasks in separate process groups */ | 913 | /* crond 3.0pl1-100 puts tasks in separate process groups */ |
914 | bb_setpgrp(); | 914 | bb_setpgrp(); |
915 | execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL); | 915 | execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, (char *) NULL); |
916 | crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, | 916 | crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, |
917 | DEFAULT_SHELL, "-c", line->cl_Shell); | 917 | DEFAULT_SHELL, "-c", line->cl_Shell); |
918 | _exit(EXIT_SUCCESS); | 918 | _exit(EXIT_SUCCESS); |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 07855f07f..c9371cce8 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -982,7 +982,7 @@ static int doit(char *str) | |||
982 | case -1: /* failure */ | 982 | case -1: /* failure */ |
983 | return 0; | 983 | return 0; |
984 | case 0: /* child */ | 984 | case 0: /* child */ |
985 | execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, my_environ); | 985 | execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, (char *) NULL, my_environ); |
986 | _exit(127); | 986 | _exit(127); |
987 | } | 987 | } |
988 | safe_waitpid(child, &status, 0); | 988 | safe_waitpid(child, &status, 0); |
diff --git a/runit/runsv.c b/runit/runsv.c index f83d58283..4155b8f43 100644 --- a/runit/runsv.c +++ b/runit/runsv.c | |||
@@ -251,7 +251,6 @@ static unsigned custom(struct svdir *s, char c) | |||
251 | int w; | 251 | int w; |
252 | char a[10]; | 252 | char a[10]; |
253 | struct stat st; | 253 | struct stat st; |
254 | char *prog[2]; | ||
255 | 254 | ||
256 | if (s->islog) return 0; | 255 | if (s->islog) return 0; |
257 | strcpy(a, "control/?"); | 256 | strcpy(a, "control/?"); |
@@ -267,13 +266,11 @@ static unsigned custom(struct svdir *s, char c) | |||
267 | /* child */ | 266 | /* child */ |
268 | if (haslog && dup2(logpipe.wr, 1) == -1) | 267 | if (haslog && dup2(logpipe.wr, 1) == -1) |
269 | warn_cannot("setup stdout for control/?"); | 268 | warn_cannot("setup stdout for control/?"); |
270 | prog[0] = a; | 269 | execl(a, a, (char *) NULL); |
271 | prog[1] = NULL; | ||
272 | execv(a, prog); | ||
273 | fatal_cannot("run control/?"); | 270 | fatal_cannot("run control/?"); |
274 | } | 271 | } |
275 | /* parent */ | 272 | /* parent */ |
276 | while (safe_waitpid(pid, &w, 0) == -1) { | 273 | if (safe_waitpid(pid, &w, 0) == -1) { |
277 | warn_cannot("wait for child control/?"); | 274 | warn_cannot("wait for child control/?"); |
278 | return 0; | 275 | return 0; |
279 | } | 276 | } |
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index 7b054e410..a77bc3fd8 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c | |||
@@ -119,7 +119,7 @@ static NOINLINE pid_t runsv(const char *name) | |||
119 | | (1 << SIGTERM) | 119 | | (1 << SIGTERM) |
120 | , SIG_DFL); | 120 | , SIG_DFL); |
121 | #endif | 121 | #endif |
122 | execlp("runsv", "runsv", name, NULL); | 122 | execlp("runsv", "runsv", name, (char *) NULL); |
123 | fatal2_cannot("start runsv ", name); | 123 | fatal2_cannot("start runsv ", name); |
124 | } | 124 | } |
125 | return pid; | 125 | return pid; |
diff --git a/util-linux/script.c b/util-linux/script.c index 2e103fd0f..a9f24b10e 100644 --- a/util-linux/script.c +++ b/util-linux/script.c | |||
@@ -181,6 +181,6 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
181 | 181 | ||
182 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ | 182 | /* Non-ignored signals revert to SIG_DFL on exec anyway */ |
183 | /*signal(SIGCHLD, SIG_DFL);*/ | 183 | /*signal(SIGCHLD, SIG_DFL);*/ |
184 | execl(shell, shell, shell_opt, shell_arg, NULL); | 184 | execl(shell, shell, shell_opt, shell_arg, (char *) NULL); |
185 | bb_simple_perror_msg_and_die(shell); | 185 | bb_simple_perror_msg_and_die(shell); |
186 | } | 186 | } |