bug-bash
[Top][All Lists]
Advanced

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

Re: trap EXIT in piped subshell not triggered during wait


From: Andreas Schwab
Subject: Re: trap EXIT in piped subshell not triggered during wait
Date: Mon, 15 Apr 2013 09:40:34 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Chet Ramey <chet.ramey@case.edu> writes:

> On 4/13/13 1:35 AM, Ilya Basin wrote:
>> Hi!
>> I've got strange behavior. Here's my script:
>> 
>>     #!/bin/bash
>>     {
>>         trap '
>>             echo "in trap EXIT">&2
>>         ' EXIT
>>         sleep 4 &
>>         echo 'sleep 2'>&2
>>         sleep 2
>>         echo 'wait $!'>&2
>>         wait $!
>>         echo 'exit'>&2
>>         exit
>>     } | cat
>> 
>> If I press Ctrl-C during wait, the trap isn't triggered.
>> If I replace curly brackets with round brackets, it works. What's the
>> difference?
>
> Thanks for the report.  This was fixed a few months ago and the fix is in
> the devel branch.

Is it correct that the EXIT trap is not executed if you let this run
through?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

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