how to test if a pipe contains data
Sven-Göran Bergh
svengbergh-busybox at yahoo.com
Mon Jan 23 09:10:25 UTC 2012
> Från: Christof Warlich <christof at warlich.name>
> Till: Harald Becker <ralda at address4me.eu>
> Kopia: busybox at busybox.net
> Skickat: söndag, 22 januari 2012 20:42
> Ämne: Re: how to test if a pipe contains data
>
> Am 22.01.2012 17:14, schrieb Harald Becker:
>> ... another one doing busy waiting in Unix shell scripts.
>
> Why do you conclude that I'm busy-waiting? I'm well aware and use Unix
> concepts like select() and threads wherever appropriate, but sometimes, even the
> most brilliant concept does not fit anyones needs.
>
> Anyhow, if it helps, or even if someone is interested, I'm happy to explain
> in detail why I need to peek for data on a filedescriptor. Otherwise, I'm
> hoping for help w.r.t. my question, being even fine with a statement from an
> experienced BusyBox expert that BusyBox cannot do what I'd like to do, as I
> could easily write an appropriate helper in C that does what I need. I just
> thought I might ask here first in case that I've overlooked something.
>
> Again, thanks a lot to anyone willing to help,
Without questioning you motives there is a dirty line that you may use if you are
willing to wait 1 sec for the result:
ash -c "busybox timeout -t 1 ash -c 'read -n0'" &> /dev/null
returns 0 on success and 143 on failure/timeout.
However, it IS hackish and I would recommend looking into the C-wrapper solution
as Laurent suggested.
/Sven
More information about the busybox
mailing list