Use saved errno in case weprintf() fails internally

This commit is contained in:
sin 2014-01-04 14:06:53 +00:00
parent 567869a8fe
commit 2dc105ebbc

View File

@ -222,15 +222,16 @@ static void
runcmd(void) runcmd(void)
{ {
pid_t pid; pid_t pid;
int status; int status, saved_errno;
pid = fork(); pid = fork();
if (pid < 0) if (pid < 0)
eprintf("fork:"); eprintf("fork:");
if (pid == 0) { if (pid == 0) {
execvp(*cmd, cmd); execvp(*cmd, cmd);
saved_errno = errno;
weprintf("execvp %s:", *cmd); weprintf("execvp %s:", *cmd);
_exit(errno == ENOENT ? 127 : 126); _exit(saved_errno == ENOENT ? 127 : 126);
} }
wait(&status); wait(&status);
if (WIFEXITED(status)) { if (WIFEXITED(status)) {