mirror of
https://github.com/sheumann/hush.git
synced 2024-12-28 07:30:23 +00:00
runsv: small optimization
*: more paranoia around passing NULL to execl[e] function old new delta custom 240 221 -19
This commit is contained in:
parent
48637e0924
commit
f09f4e015b
@ -775,7 +775,7 @@ ForkJob(const char *user, CronLine *line, int mailFd,
|
|||||||
}
|
}
|
||||||
/* crond 3.0pl1-100 puts tasks in separate process groups */
|
/* crond 3.0pl1-100 puts tasks in separate process groups */
|
||||||
bb_setpgrp();
|
bb_setpgrp();
|
||||||
execlp(prog, prog, cmd, arg, NULL);
|
execlp(prog, prog, cmd, arg, (char *) NULL);
|
||||||
crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg);
|
crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg);
|
||||||
if (mail_filename) {
|
if (mail_filename) {
|
||||||
fdprintf(1, "Exec failed: %s -c %s\n", prog, arg);
|
fdprintf(1, "Exec failed: %s -c %s\n", prog, arg);
|
||||||
@ -912,7 +912,7 @@ static void RunJob(const char *user, CronLine *line)
|
|||||||
}
|
}
|
||||||
/* crond 3.0pl1-100 puts tasks in separate process groups */
|
/* crond 3.0pl1-100 puts tasks in separate process groups */
|
||||||
bb_setpgrp();
|
bb_setpgrp();
|
||||||
execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL);
|
execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, (char *) NULL);
|
||||||
crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user,
|
crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user,
|
||||||
DEFAULT_SHELL, "-c", line->cl_Shell);
|
DEFAULT_SHELL, "-c", line->cl_Shell);
|
||||||
_exit(EXIT_SUCCESS);
|
_exit(EXIT_SUCCESS);
|
||||||
|
@ -982,7 +982,7 @@ static int doit(char *str)
|
|||||||
case -1: /* failure */
|
case -1: /* failure */
|
||||||
return 0;
|
return 0;
|
||||||
case 0: /* child */
|
case 0: /* child */
|
||||||
execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, my_environ);
|
execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, (char *) NULL, my_environ);
|
||||||
_exit(127);
|
_exit(127);
|
||||||
}
|
}
|
||||||
safe_waitpid(child, &status, 0);
|
safe_waitpid(child, &status, 0);
|
||||||
|
@ -251,7 +251,6 @@ static unsigned custom(struct svdir *s, char c)
|
|||||||
int w;
|
int w;
|
||||||
char a[10];
|
char a[10];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *prog[2];
|
|
||||||
|
|
||||||
if (s->islog) return 0;
|
if (s->islog) return 0;
|
||||||
strcpy(a, "control/?");
|
strcpy(a, "control/?");
|
||||||
@ -267,13 +266,11 @@ static unsigned custom(struct svdir *s, char c)
|
|||||||
/* child */
|
/* child */
|
||||||
if (haslog && dup2(logpipe.wr, 1) == -1)
|
if (haslog && dup2(logpipe.wr, 1) == -1)
|
||||||
warn_cannot("setup stdout for control/?");
|
warn_cannot("setup stdout for control/?");
|
||||||
prog[0] = a;
|
execl(a, a, (char *) NULL);
|
||||||
prog[1] = NULL;
|
|
||||||
execv(a, prog);
|
|
||||||
fatal_cannot("run control/?");
|
fatal_cannot("run control/?");
|
||||||
}
|
}
|
||||||
/* parent */
|
/* parent */
|
||||||
while (safe_waitpid(pid, &w, 0) == -1) {
|
if (safe_waitpid(pid, &w, 0) == -1) {
|
||||||
warn_cannot("wait for child control/?");
|
warn_cannot("wait for child control/?");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ static NOINLINE pid_t runsv(const char *name)
|
|||||||
| (1 << SIGTERM)
|
| (1 << SIGTERM)
|
||||||
, SIG_DFL);
|
, SIG_DFL);
|
||||||
#endif
|
#endif
|
||||||
execlp("runsv", "runsv", name, NULL);
|
execlp("runsv", "runsv", name, (char *) NULL);
|
||||||
fatal2_cannot("start runsv ", name);
|
fatal2_cannot("start runsv ", name);
|
||||||
}
|
}
|
||||||
return pid;
|
return pid;
|
||||||
|
@ -181,6 +181,6 @@ int script_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* Non-ignored signals revert to SIG_DFL on exec anyway */
|
/* Non-ignored signals revert to SIG_DFL on exec anyway */
|
||||||
/*signal(SIGCHLD, SIG_DFL);*/
|
/*signal(SIGCHLD, SIG_DFL);*/
|
||||||
execl(shell, shell, shell_opt, shell_arg, NULL);
|
execl(shell, shell, shell_opt, shell_arg, (char *) NULL);
|
||||||
bb_simple_perror_msg_and_die(shell);
|
bb_simple_perror_msg_and_die(shell);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user