On 3/11/23 6:41 AM, zju wrote:

The change was made in this pr:
https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=ea31c00845c858098d232bd014bf27b5a63a668b
 
<https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=ea31c00845c858098d232bd014bf27b5a63a668b>

The logic goes like this for interactive shells (non-interactive shells
don't ignore SIGTERM):


block SIGTERM in the parent
set the SIGTERM handler to SIG_DFL in the parent
fork, so the child, which still has SIGTERM blocked, has no pending signals
in the parent, restore the SIGTERM handler to SIG_IGN
if fork fails, abandon, reset the signal mask, and jump back to top level
        - this is where other pipeline processes get sent SIGTERM       
in the child, unblock SIGTERM -- if it received a SIGTERM after fork, it
will handle it now and exit due to the disposition being SIG_DFL

You might want to run a system call tracer and look at calls to kill and
sigaction.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to