summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2017-07-08 00:24:32 +0200
committerDenys Vlasenko2017-07-08 00:24:32 +0200
commit13102634bb38befd80fafb5d2ebd915d7dcf0c5f (patch)
treeff7700cf716b079a66e1a8c29ae1e5d86714f8d4 /shell
parent840a4355d035efc360eeefe5da8a11e47b3c80d3 (diff)
downloadbusybox-13102634bb38befd80fafb5d2ebd915d7dcf0c5f.zip
busybox-13102634bb38befd80fafb5d2ebd915d7dcf0c5f.tar.gz
hush: explain why wait5.tests is failing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/shell/hush.c b/shell/hush.c
index df96e6f..b131f60 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7401,6 +7401,10 @@ static int process_wait_result(struct pipe *fg_pipe, pid_t childpid, int status)
printf(JOB_STATUS_FORMAT, pi->jobid,
"Done", pi->cmdtext);
delete_finished_bg_job(pi);
+//bash deletes finished jobs from job table only in interactive mode, after "jobs" cmd,
+//or if pid of a new process matches one of the old ones
+//(see cleanup_dead_jobs(), delete_old_job(), J_NOTIFIED in bash source).
+//Testcase script: "(exit 3) & sleep 1; wait %1; echo $?" prints 3 in bash.
}
} else {
/* child stopped */
@@ -9899,6 +9903,15 @@ static int FAST_FUNC builtin_wait(char **argv)
ret = job_exited_or_stopped(wait_pipe);
if (ret < 0)
ret = wait_for_child_or_signal(wait_pipe, 0);
+//bash immediately deletes finished jobs from job table only in interactive mode,
+//we _always_ delete them at once. If we'd start doing that, this (and more)
+//would be necessary to avoid accumulating dead jobs:
+# if 0
+ else {
+ if (!wait_pipe->alive_cmds)
+ delete_finished_bg_job(wait_pipe);
+ }
+# endif
}
/* else: parse_jobspec() already emitted error msg */
continue;