printf, data presentation

Guy Harris guy at auspex.UUCP
Sat Jan 7 04:22:37 AEST 1989


>If I understand your need, the fcntl VMIN and VTIM parameters

"ioctl(TCSETA)" and company, not "fcntl".

>may help.  If you set VMIN=0 and VTIM>0, read() returns immediately
>if characters are available, or in VTIM 10th-secs if the queue is dry.

This works on UNIXes that have VMIN and VTIME (S3, S5, SunOS 4.0, some
others).  It doesn't work on older UNIXes, or non-UNIX systems; I think
he wanted a routine that would, on all (or, at least, most) systems, do
what was appropriate on that system (whether UNIX or not).

>I use VMIN=0,VTIM=1 to grab the next char, or return immediately if
>none is available.

Try VTIME=0 instead (although this may not work under S3); that will
return immediately, rather than after 1/10 second (which VTIME=1 does).

>>Even a blocking version (that would return a char once typed,
>>without waiting for a newline) would be useful.
>
>Try reading with VMIN=1,VTIM=0.  This is akin to the Berkeley CBREAK mode.

Actually, the equivalent of turning on V7 CBREAK (not Berkeley - they
didn't invent CBREAK, AT&T did) is turning ICANON off and setting VMIN
to 1 and VTIME to 0.  VMIN and VTIME are meaningful only if ICANON is off.



More information about the Comp.lang.c mailing list