bug-bash
[Top][All Lists]
Advanced

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

Re: read -t 0 anomaly


From: Kunszt Árpád
Subject: Re: read -t 0 anomaly
Date: Fri, 04 Oct 2013 14:08:43 +0200
User-agent: KMail/4.10.5 (Linux/3.10.7-gentoo-syrius; KDE/4.10.5; x86_64; ; )

On 2013. October 4. 14:51:00 Pierre Gaston wrote:
> On Fri, Oct 4, 2013 at 2:20 PM, Kunszt Árpád 
...
> 
> 
> There is a race condition, you cannot know if echo will run before read.

I see, and it's logical. But this stills confuses me.

address@hidden ~ $ for(( i=0; i<10; i++ )); do echo -n "" | { sleep 1s; read -t 
0; echo $?; } ; done | sort | uniq -c
     10 0

I expected that the read will return non-zero in this case. I think it returned 
with zero because the STDIN was still open. The docs said "read returns success 
if input is available on the specified file descriptor, failure otherwise". 
There wasn't any data on the file descriptor, it was just open.

Am I still doing something wrong? Or I just misunderstanding the meaning of 
"input is available" term? I'm not a native English speaker (as you can se from 
my mails clearly).

Thanks,

Arpad Kunszt



reply via email to

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