On 11/7/26 9:48 AM, Christopher Ozsvath wrote:

Description:
A non-interactive shell that receives SIGINT while it waits for a
child (command substitution or a foreground external command) can
livelock at 100% CPU, forever, even when SIGINT is ignored with
trap '' INT.

strace of the stuck process shows this loop, with si_pid equal to
the shell's own pid:

--- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=<self>} ---
getpid() = <self>
kill(<self>, SIGINT) = 0
rt_sigreturn({mask=[CHLD]}) = 0
... repeats ...

Our reading of jobs.c (5.3, wait_for, around line 3093): when
job_control == 0 || (subshell_environment & SUBSHELL_COMSUB), the
code does

temp_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
if (temp_sigint_handler == wait_sigint_handler)
...
else
old_sigint_handler = temp_sigint_handler;

This isn't what the bash-5.3 code looks like. It was changed a little more
than three years ago, the result of

https://lists.gnu.org/archive/html/bug-bash/2023-10/msg00131.html


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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to