how to test if a pipe contains data

ralda at gmx.de ralda at gmx.de
Sun Jan 22 16:14:31 UTC 2012


Ohh no ...

> is there a way to test whether data is available for reading from a pipe 
> with busybox? With bash, I could do "read -t0" and check the exit 
> status, but unfortunately, the -t option is not available in the busybox 
> read command.

... another one doing busy waiting in Unix shell scripts. Hey Linux
works pretty fine with multi processes, so it is better to setup a
separate process that waits for reception of data and do the data
processing. Behalf that processing send signals (in any means) to other
processes that need to be informed. Don't try to put everything in a
single process and poll for which data stream needs processing. That's
what is the Unix concept for this and why there is usually no polling
check in standard shells. "read -tN" is a bash-ishm only worth of
limiting the time waited for user responses (IMHO).

--
Harald


More information about the busybox mailing list