This was unexpected to me, but doing a couple of builds revealed it was reproducible on bash's latest code from git, but not bash 4.0. As such git bisect
was helpful in pinpointing the following commit as being responsible:
% git bisect good
ac50fbac377e32b98d2de396f016ea81e8ee9961 is the first bad commit
commit ac50fbac377e32b98d2de396f016ea81e8ee9961
Author: Chet Ramey <chet.ramey@case.edu>
Date: Wed Feb 26 09:36:43 2014 -0500
Bash-4.3 distribution sources and documentation
Bash's individual git commits tend to be fairly large and not super tightly scoped, but spending a few minutes going through that commit shows a number of changes to how readline handles SIGTERM, including a new rl_signal_event_hook which SIGTERM is supposed to bypass, and plenty of new places that we check for SIGTERM and call termsig_handler
.
Part of those changes matches up with this new entry in in the changelog:
Readline calls an application-set event hook (rl_signal_event_hook) after it gets a signal while reading input (read returns -1/EINTR but readline does not handle the signal immediately) to allow the application to handle or otherwise note it. Not currently called for SIGHUP or SIGTERM.
Judging by this message, I believe the change in behaviour may not be intentional.
I'm going to forward this thread to the bug-bash mailing list in the hopes of getting to the bottom of whether this was intentional or not.
bash
in my terminal emulator, isn't that an interactive session? That's what I killed by runningkill <pid>
(inside another terminal emulator). – finefoot Mar 04 '20 at 16:52HUP
("hang-up") signal, notTERM
. – Kusalananda Mar 04 '20 at 16:57bash --noediting
will not be killed by anSIGTERM
. Nor will bash kill itself by runningkill -TERM $$
. See here for something similar. – Mar 04 '20 at 17:33