runsv: small optimization

*: more paranoia around passing NULL to execl[e]

function                                             old     new   delta
custom                                               240     221     -19
This commit is contained in:
Denis Vlasenko
2009-02-26 12:29:59 +00:00
parent 48637e0924
commit f09f4e015b
5 changed files with 7 additions and 10 deletions

View File

@@ -251,7 +251,6 @@ static unsigned custom(struct svdir *s, char c)
int w;
char a[10];
struct stat st;
char *prog[2];
if (s->islog) return 0;
strcpy(a, "control/?");
@@ -267,13 +266,11 @@ static unsigned custom(struct svdir *s, char c)
/* child */
if (haslog && dup2(logpipe.wr, 1) == -1)
warn_cannot("setup stdout for control/?");
prog[0] = a;
prog[1] = NULL;
execv(a, prog);
execl(a, a, (char *) NULL);
fatal_cannot("run control/?");
}
/* parent */
while (safe_waitpid(pid, &w, 0) == -1) {
if (safe_waitpid(pid, &w, 0) == -1) {
warn_cannot("wait for child control/?");
return 0;
}