On 4/9/14, 6:43 AM, Håkon Bugge wrote: > Bash Version: 4.2 > Patch Level: 45 > Release Status: release > > Description: > This script never terminates:
Bash holds on to processes and their status until it's notified the user about the status of terminated processes. It's especially careful to hold onto the status of the current job (the last background job started) until the user's been notified. It seems like you're making unwarranted assumptions about what `jobs -p' will return. You have a couple of choices: 1. Use `wait', which, as Greg suggested, is much better suited for this task. 2. Since you're interested in running jobs, ask for running jobs using `jobs -rp' instead of running `jobs -p' and assuming things about the output. 3. Throw a call to `jobs' in there so the shell thinks it's notified the user about terminated jobs. This is essentially the reason that it `works' in an interactive shell: the shell does the notification about terminated jobs asynchronously when it's interactive. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/