From: Joey Hess Date: Tue, 23 Feb 2010 18:59:20 +0000 (-0500) Subject: parallel: Fix exit code handling when commands are specified after -- X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=448a100d287f2cc183f305f9e28723776f10b1bf;p=moreutils parallel: Fix exit code handling when commands are specified after -- --- diff --git a/debian/changelog b/debian/changelog index 4049ddd..3670373 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ moreutils (0.39) UNRELEASED; urgency=low * Cap sillyness. Closes: #570815 + * parallel: Fix exit code handling when commands are specified after -- -- Joey Hess Sun, 21 Feb 2010 13:16:10 -0500 diff --git a/parallel.c b/parallel.c index c78e830..94559ff 100644 --- a/parallel.c +++ b/parallel.c @@ -70,7 +70,13 @@ void exec_child(char **command, char **arguments, int replace_cb, int nargs) { } else { if (fork() == 0) { - exit(system(arguments[0])); + int ret=system(arguments[0]); + if (WIFEXITED(ret)) { + exit(WEXITSTATUS(ret)); + } + else { + exit(1); + } } } return; @@ -82,10 +88,12 @@ int wait_for_child(int options) { infop.si_pid = 0; waitid(P_ALL, id_ignored, &infop, WEXITED | options); - if (infop.si_pid == 0) + if (infop.si_pid == 0) { return -1; /* Nothing to wait for */ - if (infop.si_code == CLD_EXITED) + } + if (infop.si_code == CLD_EXITED) { return infop.si_status; + } return 1; }