Check the exit status and return it from the parent process
This commit is contained in:
parent
7ec616e1e5
commit
567869a8fe
9
xargs.c
9
xargs.c
|
@ -229,10 +229,15 @@ runcmd(void)
|
||||||
eprintf("fork:");
|
eprintf("fork:");
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
execvp(*cmd, cmd);
|
execvp(*cmd, cmd);
|
||||||
eprintf("execvp %s:", *cmd);
|
weprintf("execvp %s:", *cmd);
|
||||||
_exit(errno == ENOENT ? 127 : 126);
|
_exit(errno == ENOENT ? 127 : 126);
|
||||||
}
|
}
|
||||||
wait(&status);
|
wait(&status);
|
||||||
if (WIFEXITED(status) && WEXITSTATUS(status) == 255)
|
if (WIFEXITED(status)) {
|
||||||
|
if (WEXITSTATUS(status) == 255)
|
||||||
exit(124);
|
exit(124);
|
||||||
|
if (WEXITSTATUS(status) == 127 ||
|
||||||
|
WEXITSTATUS(status) == 126)
|
||||||
|
exit(WEXITSTATUS(status));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user