bug-bash
[Top][All Lists]
Advanced

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

Re: read -t0 may report that input is available where none is possible


From: Dale R. Worley
Subject: Re: read -t0 may report that input is available where none is possible
Date: Sun, 21 Nov 2021 14:54:55 -0500

More to the essence:

    $ read -t0 </dev/null ; echo $?
    0
    $

Presumably every implementation is ultimately calling select(), and so
what is really being tested is "reading would not block".  But as you
can see "would not block" is equivalent to "an input byte is available
or the fd is at EOF".  Since the implementation is unlikely to change
(and it would probably break deployed code), we should update the
documentation to

    If timeout is 0, read returns immediately, without trying to read
    any data. The exit status is 0 if reading the specified file
    descriptor would not block (i.e., input is available or it has EOF),
    non-zero otherwise."

Dale



reply via email to

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