On 4/25/23 2:41 PM, Guldrelokk wrote:
POSIX has the following to say with respect to the 'jobs' utility:
When jobs reports the termination status of a job, the shell shall remove
its process ID from the list of those known in the current shell
execution environment
With Bash, this is not the case for 'jobs' called from within a SIGCHLD
handler.  This can be verified with:
sh -c 'set -m; trap "jobs %cat; jobs %cat" CHLD; cat </dev/null & wait %cat; jobs %cat; jobs %cat'

Thanks for the report. The jobs builtin now removes jobs from the jobs
list even inside traps, as POSIX requires.


Because job tables are not inherited by subshells, capturing the output of
'jobs' requires using a named pipe, which is relatively cumbersome.

This is not quite true. Bash makes special provisions so you can use
command substitution, process substitution, or even a pipeline to get
the jobs list.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to