On 3/19/23 11:10 PM, Grisha Levit wrote:
If an EXIT trap is executed after receipt of a terminating signal,
waiting on a process substitution within the trap can fail:

The terminating signal handler cleans up FIFOs and any running procsubs
before running the exit trap, which is the last thing it does.

$ (trap 'wait $!; echo $?' EXIT; : <(:); kill 0)
-bash: wait: pid 83694 is not a child of this shell
127

Interestingly, if an external command or a subshell is executed after
the process substitution is started but prior to receipt of the
signal, the `wait' works fine:

$ (trap 'wait $!; echo $?' EXIT; : <(:); (:); kill 0)

Because the procsub gets reaped before the terminating signal arrives.

--
``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