From a1a2b5fe9f8e474c55308637caa3f4852f52b480 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 23 Feb 2010 15:35:34 -0500 Subject: [PATCH] parallel: Fix logic error in code handling -l that could make parallel return a bogus 255 exit code when all jobs succeeded. Closes: #569617 --- debian/changelog | 2 ++ parallel.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index fe89fdf..b0ac071 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ moreutils (0.39) UNRELEASED; urgency=low * parallel: Fix exit code handling when commands are specified after -- * parallel: Make -j 0 do something reasonable (start all jobs at once). * parallel: Fix to really avoid running new jobs when load is too high. + * parallel: Fix logic error in code handling -l that could make parallel + return a bogus 255 exit code when all jobs succeeded. Closes: #569617 -- Joey Hess Sun, 21 Feb 2010 13:16:10 -0500 diff --git a/parallel.c b/parallel.c index 19f341a..6bd4665 100644 --- a/parallel.c +++ b/parallel.c @@ -211,7 +211,7 @@ int main(int argc, char **argv) { argidx += argsatonce; curjobs++; } - + if (maxjobs == 0 || curjobs == maxjobs) { returncode |= wait_for_child(0); curjobs--; @@ -222,10 +222,10 @@ int main(int argc, char **argv) { sleep(1); /* XXX We should have a better * heurestic than this */ r = wait_for_child(WNOHANG); - if (r > 0) { + if (r > 0) returncode |= r; + if (r != -1) curjobs--; - } } } while (curjobs > 0) { -- 2.39.5