Re: Bash: sleep execution issue with bash loadable builtins
From:
Chet Ramey
Subject:
Re: Bash: sleep execution issue with bash loadable builtins
Date:
Mon, 27 Nov 2017 12:39:12 -0800
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0
On 11/27/17 4:17 AM, Thiruvadi Rajaraman wrote:
> Hi,
>
> Found a 'sleep' execution issue with bash loadable builtins and has
> performed
> the below sleep test on bash-4.4-rc1.
That's an interesting one. It looks like the SIGCHLD interrupts the select
loop, even though bash supplies SA_RESTART when installing its SIGCHLD
handler. It's probably too hard to restart it in general, since select
doesn't necessarily modify its timeval argument when it returns early
(Linux does; many other OSs do not).
There is a problem with your fix in that, in most cases, you've just made
everything that uses this function non-interruptible, especially in an
interactive shell. I think a better fix would be to change fsleep() to cope
with select(2) being interrupted using the bash primitives that deal with
signal and trap handling.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/