Keyboard check under UNIX Sys V?

jeff at cdp.UUCP jeff at cdp.UUCP
Wed Oct 1 05:11:00 AEST 1986


i'm not sure if i agree that using VMIN/VTIME and raw mode is
the "preferred" way of doing unblocked reads, but it is one way.
your preference may depend on your application.  in the applications
i've done, i prefer to use O_NDELAY.  anyway, here are a few
issues you might want to consider:

- if you use "raw" mode, this means that your application must
provide its own erase and kill handling.
- a note on ungetc: you cannot ungetc something before you do a
(buffered) stdio read from the input stream.  this is documented
in the manual page, although in practice, not all systems are
this strict.
- an alternative to ungetc is to maintain a one character lookahead
buffer.  if you have one central input routine, then this change
is easy to pop into place.  if you use many different input routines,
then you have more work on your hands.
- the alternative approach is to open the input stream with
O_NDELAY.  however, since you probably don't want unblocked
reads all the time, a convenient hack is to open up a separate
descriptor for stdin with O_NDELAY, and use that descriptor
only for readahead.

if this sounds unnecessarily complicated, that's because it is.
the berkeley users have FIONREAD, which is much nicer...



More information about the Comp.unix.wizards mailing list