Re: My script makes a defunct subshell and sticks on read
From:
Chet Ramey
Subject:
Re: My script makes a defunct subshell and sticks on read
Date:
Wed, 31 Jan 2018 10:39:53 -0500
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.2
On 1/31/18 7:44 AM, Øyvind Hvidsten wrote:
> Here. Now it's reading from stdin, and it locks up after a few seconds
> every time. No fifo's, pipes, non-standard file descriptors or anything.
>
> bash -c 'for ((i=0; ; i++)); do (( i%100 )) || printf "%s\n" "$i"; read -t
> 0.00001; done'
This is definitely a signal issue. No matter how you check, if a signal
arrives between the check and the read, and all the signal handler is
allowed to do is to set a flag, the read will block.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/