[net.unix-wizards] Non-blocking input from a tty

cosell%bbn-unix@sri-unix.UUCP (12/07/83)

From:  Bernie Cosell <cosell@bbn-unix>

Can anyone remind if there is a way (however clunky) to do a non-blocking
read from a tty that is pretty portable?  I thought that there was some
magic I could do with pipes and signals, but I can't see a way to make it
work.  

Here's the scenario for the general case I'm interested in: to be able to
read and write from one terminal while be able to "respond" to a character
typed on another terminal; no characters must ever get lost.  The specific
case I'm working on uses just one terminal: I am using a funny (non ^s/^q)
flow control and so have to handle my own.  No real problem but I can't
figure out how to check if the terminal has said "stop" while I am in a
loop pumping output to it.

I had another peculiar query: did the folks who wrote stdio do so carefully
enough that they will never lose any characters if a signal goes off
while stdio is doing one of its reads or writes?  Again, I am trying to be
very very clean about not losing any I/ or /O and it occurred to me that if
the stdio-writers were not careful enough even using the clock could do you
in.

Thanks
   /Bernie (cosell@bbn-unix)

thomas@utah-gr.UUCP (Spencer W. Thomas) (12/10/83)

Most current unices allow either (1) non-blocking reads or (2) ability
to check to see if input is available.  The names of these facilities
differ between the USG and BSD unices.

=Spencer