On 30/01/18 22:51, Chet Ramey wrote:
On 1/30/18 3:04 PM, Øyvind Hvidsten wrote:

Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
     Running the included script, which does nothing useful but is cut down
a lot to demonstrate the issue, my main computer (amd64 based) counts to
several million, then Bash stops responding, using 100% cpu and ends up
with a defunct subshell. On my Raspberry Pi, running Raspbian Stretch and
the same version of Bash (4.4.12), the same thing happens after only a few
thousand iterations.

Repeat-By:
     for ((i=0; ; i++)); do ((i%100)) || echo $i; exec {fd}<> >(:); read -t
0.001 -u $fd; exec {fd}>&-; done

In one sense, it's surprising that this works at all. You're opening a file
descriptor read-write (and trying to read from it) to a pipe that's opened
for writing only (the >(command) form is supposed to be used by processes
that write to the resulting file).


Sorry for the spam. I just wanted to say it also happens without the subshell, when reading from a FIFO. In my first three tests, it stopped after 16500, 3100 and 125900 iterations, so it can (randomly) take a while.

----------------------
fifo=$(mktemp -u)
mkfifo "$fifo"
trap "rm $fifo" EXIT

echo "FIFO: $fifo"

exec {w}<> "$fifo"
for ((i=0; ; i++)); do
    (( i%100 )) || printf "%s\n" "$i"
    read -t 0.001 -u $w
done
----------------------

Reply via email to