bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


PROMPT_COMMAND='if [ $(ls /proc/$$/fd | wc -l) -gt 10 ]; then echo "leaking fds"; fi'


# 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:

CENTOS 4.2.46(2)-release
OPENSUSE 5.0.0(1)-release, 4.3.42(1)-release, 4.4.23(1)-release
debian stretch 5.0.2(1)-release, 4.4.12(1)-release
ubuntu18.04 4.4.19(1)-release


Thanks
Best regards
Tycho







reply via email to

[Prev in Thread] Current Thread [Next in Thread]