]> err.no Git - moreutils/commitdiff
parallel: Fix exit code handling when commands are specified after --
authorJoey Hess <joey@gnu.kitenet.net>
Tue, 23 Feb 2010 18:59:20 +0000 (13:59 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Tue, 23 Feb 2010 18:59:20 +0000 (13:59 -0500)
debian/changelog
parallel.c

index 4049ddd3d646de41fb392da2a572340a87f41d7d..36703733c2a672577994b3bf236c43d056ad8e02 100644 (file)
@@ -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 <joeyh@debian.org>  Sun, 21 Feb 2010 13:16:10 -0500
 
index c78e830e9fa6a9ab8ec7c7172c58ccef29e1e5cb..94559ff049c668f4642e5a6102e4fde37fa65b30 100644 (file)
@@ -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;
 }