How can I read keyboard without stopping

Ronald G Minnich rminnich at super.ORG
Tue Aug 30 03:52:08 AEST 1988


In article <1267 at ficc.UUCP> peter at ficc.UUCP (Peter da Silva) writes:
>I believe that once upon a time on some system a stat() on a pipe would
>return the number of characters in a pipe. Wouldn't it make sense to
>have stat() on a terminal device return the number of characters available?
You would think so, wouldn't you. 
On most of the systems i have tried it on it 
always returns 0 on ttys. 
That seems quite wrong to me, but there you are. 
Also, on most unix's you can't tell whether there are 0 bytes
to read because of an eof or 0 bytes cause nothing is there yet. 
I haven't looked lately to see if such a thing has been added; on 4.2-like
systems you had to to shenanigans with select() and FIONREAD to determine
that you were at EOF. And then you had to try to read 1 byte
to get the rest of the kernel to realize you really WERE
at EOF. Annoying. So many other OSs have a way of just TELLING you 
you are at EOF with a simple function call.
There are funny little holes in the Unix filesystem even now ...
ron



More information about the Comp.unix.wizards mailing list