help-bash
[Top][All Lists]
Advanced

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

Re: Infinite loop with error trap and subshell


From: Samir Aguiar
Subject: Re: Infinite loop with error trap and subshell
Date: Tue, 16 Nov 2021 11:52:22 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

Hi Chet,

On 30/10/2021 17:03, Chet Ramey wrote:
Should trap handlers be able to run recursively? That is, in an ERR trap
handler (which is a special pseudo-signal), should a failing command cause
the trap handler to run again? This is how other trap handlers behave.

If trap handlers should be allowed to run recursively, should that extend
to the special shell pseudo-signals (ERR/RETURN/DEBUG) or be restricted to
the ones that correspond to actual signals? The shell allows the special
pseudo-signals to run trap handlers recursively.

If you put these things together, you see what happens. The subshell
started to run the forked while loop inherits the ERR trap `forgets' that
it's running a trap handler to allow recursive trap handlers.

Yes, that makes sense. Given your explanation, the reasonable fix for us was to clear the ERR trap handler right in the beginning of the handler function.

Thanks for you help!

Kind regards,
Samir Aguiar



reply via email to

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