Checking for waiting characters

Doug Gwyn gwyn at brl-smoke.ARPA
Sat May 10 10:01:59 AEST 1986


In article <1364 at ihuxy.UUCP> ejbjr at ihuxy.UUCP (Branagon) writes:
>> 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.
>
>The easiest way I've found to do this is to set an alarm, and use a signal
>trapping function (see alarm(2) and signal(2)).  The alarm can be set once
>at the beginning, or reset after each character.  I'm not sure if alarm()
>is sysV specific or not.

No, alarm() has been in all UNIXes since 6th Edition.
However, the alarm signal can mangle I/O involving "slow"
devices (typically terminal ports), so it is not suitable
for some applications like this.  Other approaches such
as using MIN,TIME are preferable.



More information about the Comp.unix.wizards mailing list