Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!rutgers!att!chinet!les
From: les@chinet.chi.il.us (Leslie Mikesell)
Newsgroups: comp.unix.xenix
Subject: Re: getc help needed
Message-ID: <9687@chinet.chi.il.us>
Date: 28 Sep 89 03:23:49 GMT
References: <2056@leah.Albany.Edu>
Reply-To: les@chinet.chi.il.us (Leslie Mikesell)
Distribution: usa
Organization: Chinet - Public Access Unix
Lines: 15

In article <2056@leah.Albany.Edu> tmm33@leah.albany.edu.UUCP (Terry McCoy) writes:
>Does anyone known what would be needed to create a function similar to getc()
>that would return control to the calling function if the buffer was empty.

You can set up a signal handler for SIGALRM and use alarm() to interrupt
the read().
Or, use fcntl() to set O_NDELAY so read() will return if no characters
are available. (Don't forget to turn it off before any write()'s).
Or, use ioctl() and set the c_cc[VMIN] and c_cc[VTIME] fields in the
termio struct to zeros and turn off ICANON. (See termio(7)).

Depending on the application, it may also be possible to do the input
in a separate process which can then block without problems.

Les Mikesell