aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-11-14 01:59:55 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-11-14 01:59:55 +0100
commitc08c3f5d262acab7082cca88d0b2a329184b133b (patch)
treef43b0d66a484627f498198cb71b9d69f51a71d03
parent2b662c5deceb43a10f815424de85c1416c379e2a (diff)
downloadbusybox-w32-c08c3f5d262acab7082cca88d0b2a329184b133b.tar.gz
busybox-w32-c08c3f5d262acab7082cca88d0b2a329184b133b.tar.bz2
busybox-w32-c08c3f5d262acab7082cca88d0b2a329184b133b.zip
hush: preparatory patch for set -o pipefail support
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 9dd30c436..126aaf074 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6309,7 +6309,8 @@ static int checkjobs(struct pipe *fg_pipe)
6309#endif 6309#endif
6310 /* Were we asked to wait for fg pipe? */ 6310 /* Were we asked to wait for fg pipe? */
6311 if (fg_pipe) { 6311 if (fg_pipe) {
6312 for (i = 0; i < fg_pipe->num_cmds; i++) { 6312 i = fg_pipe->num_cmds;
6313 while (--i >= 0) {
6313 debug_printf_jobs("check pid %d\n", fg_pipe->cmds[i].pid); 6314 debug_printf_jobs("check pid %d\n", fg_pipe->cmds[i].pid);
6314 if (fg_pipe->cmds[i].pid != childpid) 6315 if (fg_pipe->cmds[i].pid != childpid)
6315 continue; 6316 continue;
@@ -6338,19 +6339,19 @@ static int checkjobs(struct pipe *fg_pipe)
6338 } 6339 }
6339 debug_printf_jobs("fg_pipe: alive_cmds %d stopped_cmds %d\n", 6340 debug_printf_jobs("fg_pipe: alive_cmds %d stopped_cmds %d\n",
6340 fg_pipe->alive_cmds, fg_pipe->stopped_cmds); 6341 fg_pipe->alive_cmds, fg_pipe->stopped_cmds);
6341 if (fg_pipe->alive_cmds - fg_pipe->stopped_cmds <= 0) { 6342 if (fg_pipe->alive_cmds == fg_pipe->stopped_cmds) {
6342 /* All processes in fg pipe have exited or stopped */ 6343 /* All processes in fg pipe have exited or stopped */
6343/* Note: *non-interactive* bash does not continue if all processes in fg pipe 6344/* Note: *non-interactive* bash does not continue if all processes in fg pipe
6344 * are stopped. Testcase: "cat | cat" in a script (not on command line!) 6345 * are stopped. Testcase: "cat | cat" in a script (not on command line!)
6345 * and "killall -STOP cat" */ 6346 * and "killall -STOP cat" */
6346 if (G_interactive_fd) { 6347 if (G_interactive_fd) {
6347#if ENABLE_HUSH_JOB 6348#if ENABLE_HUSH_JOB
6348 if (fg_pipe->alive_cmds) 6349 if (fg_pipe->alive_cmds != 0)
6349 insert_bg_job(fg_pipe); 6350 insert_bg_job(fg_pipe);
6350#endif 6351#endif
6351 return rcode; 6352 return rcode;
6352 } 6353 }
6353 if (!fg_pipe->alive_cmds) 6354 if (fg_pipe->alive_cmds == 0)
6354 return rcode; 6355 return rcode;
6355 } 6356 }
6356 /* There are still running processes in the fg pipe */ 6357 /* There are still running processes in the fg pipe */