bug-bash
[Top][All Lists]
Advanced

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

Re: 100% cpu with: while true ;do read < /dev/null ;done


From: Mike Frysinger
Subject: Re: 100% cpu with: while true ;do read < /dev/null ;done
Date: Thu, 22 Oct 2009 01:22:23 -0400
User-agent: KMail/1.12.2 (Linux/2.6.31.4; KDE/4.3.2; x86_64; ; )

On Thursday 22 October 2009 01:10:33 Jan Schampera wrote:
> Jo King schrieb:
> > Fix:
> >     [ bash/the read code could
> >  detect there's no stdin and sleep for 1-2 seconds]
> 
> If you consider this as a bug, the bug is not in Bash (but in the
> application).
> 
> In short you request that read should wait a second, once it got a
> end-of-file signalled, I don't think this is the way to 'fix' this
> 'bug'. It has far too many side effects or impacts to other uses of
> read. Fix your application instead, query the exit code of read
> (non-zero on EOF, timeout or error) and insert a conditional sleep
>  yourself.

and the code can easily be "fixed" b adding "-t 1" to the read invocation
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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