[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: jobs builtin inside SIGCHLD trap doesn't clean up terminated jobs
From: |
Chet Ramey |
Subject: |
Re: jobs builtin inside SIGCHLD trap doesn't clean up terminated jobs |
Date: |
Wed, 3 May 2023 09:04:05 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 |
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 chet@case.edu http://tiswww.cwru.edu/~chet/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: jobs builtin inside SIGCHLD trap doesn't clean up terminated jobs,
Chet Ramey <=