Checking for waiting characters

Admin root at ptsfa.UUCP
Tue May 6 11:48:20 AEST 1986


In article <470 at brl-smoke.ARPA> KEN%NJITCCCC.BITNET at wiscvm.wisc.edu (Kenneth Ng) writes:
>On Unix System V version 2 on an AT&T 3b5, has anyone been able to
>successfully test if characters are pending?  I've got an application
>that needs to time out after a certain amount of time if no characters
>come through.  Every read I've done seems to wait for characters.
>To date, I've tried setting -icanon on standard in, I've set the EOL
>value to 50, which according to the documentation should give me a time
>out of 5 seconds, and I've set the O_NDELAY on a fcntl() to standard
>input.  Any help or suggestions would be greatly appreciated.


When in raw (c_lflag & ~ICANON) mode the MIN and TIME (EOF and EOL, respectively)
you can set both the minimum number of characters to wait for AND the
maximum time to wait AFTER the first character arrives.

There were problems with this prior to SVR2 which once were described as
a documentation bug, but they work now.

Couple these with O_NDELAY and you can do what you want.



More information about the Comp.unix.wizards mailing list