[Top][All Lists]

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

Re: My script makes a defunct subshell and sticks on read

From: Øyvind Hvidsten
Subject: Re: My script makes a defunct subshell and sticks on read
Date: Tue, 30 Jan 2018 22:54:19 +0100
User-agent: Cathedral Secure Mail v0.8

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

     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.

     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).

Yes. It's actually a rather neat hack if one wants to sleep without the "sleep" command or bash addons. I'm chasing a more complex issue though, and I'm wondering if whatever happens here could be happening with subshells in general.

reply via email to

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