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, 1 Oct 2021 18:16:15 +0000 (UTC)

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'.

 -Mark

On Friday, October 1, 2021, 07:02:34 AM PDT, Chet Ramey <chet.ramey@case.edu> 
wrote: 





On 9/30/21 7:24 PM, Mark March wrote:

> If execfail is set, a failed exec does not cause a non-interactive shell to 
> exit, but it seems to reset the EXIT trap:


Yes. When the shell runs `exec', it assumes the execed program will overlay
the shell process. To make that happen transparently, it has to undo things
it has done: it ends job control and restores the original process groups,
it restores the signal dispositions that it got from its parent, and it
clears other shell state like the EXIT trap.

If the exec fails, it tries to restore some things as well as it can, but
it doesn't try to restore any traps.


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