bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wait on procsub in EXIT trap


From: Chet Ramey
Subject: Re: wait on procsub in EXIT trap
Date: Tue, 21 Mar 2023 15:28:39 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0

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    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]