Leaking file descriptors on fast SIGINT's in PROMPT_COMMAND, PS1
From:
Tycho Kirchner
Subject:
Leaking file descriptors on fast SIGINT's in PROMPT_COMMAND, PS1
Date:
Thu, 28 Mar 2019 13:01:46 +0100
Dear bash-maintainers,
the *interactive* bash leaks (pipe-)file-descriptors when fast
interrupts (SIGINT) occur. The bug occurs on all bash-versions tested
(see below), including 5.0.2(1)-release.
The bug is most easily reproduced using two terminals.
# Terminal one:
# Setup a PROMPT_COMMAND (PS1 also possible) which
# causes the creation of a pipe, e.g.
# find out our PID
echo $$
# ----------------------
# Terminal two:
# send interrupts to the other terminal using the PID above.
# The bug is more easily reproduced, when
# switching to Terminal one and pressing Ctrl+C multiple times.
# Hit/ hold Ctrl+C until seeing the above message "leaking fds".
# Stop below while-loop and examine /proc/$PID/fd
# A number of pipe descriptors should show up.
while true; do kill -INT $PID; sleep 0.01; done
-------------------------------------------------------
Machine: x86_64
OS: linux-gnu
Several bash-version were tested on different Gnu/Linux-Distributions,
including: