bug-bash
[Top][All Lists]
Advanced

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

Re: EXIT trap is not executed after an exec failure in a non-interactive


From: Mark March
Subject: Re: EXIT trap is not executed after an exec failure in a non-interactive shell
Date: Fri, 8 Oct 2021 18:34:25 +0000 (UTC)

>I'll look at changing that

Thank you. I agree, making traps behave the same after an exec failure as after 
any other failed builtin is a better course of action. It will make the trap 
facility stronger. execve failures are not that uncommon, and are hard to 
predict in advance. execve(2) man page lists 24 failure conditions! Since they 
can't predict exec failures, scripts that use traps and must handle exec 
failures will have to save the traps before pretty much every call to exec that 
takes a command name. This is quite a bit of work to put on bash users. On the 
other hand, not doing this will lead to subtle bugs where cleanup code will 
suddenly not run, or processes unexpectedly catch signals that have been 
previously blocked.

-Mark



On Friday, October 8, 2021, 08:02:31 AM PDT, Chet Ramey <chet.ramey@case.edu> 
wrote: 





On 10/1/21 2:16 PM, Mark March wrote:
> Ok, thank you for clarifying. There is nothing in the documentation about 
> this behavior as far as I can tell. I would suggest adding a line about traps 
> getting reset after a failed exec to the paragraph on 'execfail'.

I think it will be a cleaner fix, and more intuitive, to make sure the
traps are preserved across a failed `exec'. I'll look at changing that

behavior.

Chet

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