getc help needed

Leslie Mikesell les at chinet.chi.il.us
Thu Sep 28 13:23:49 AEST 1989


In article <2056 at leah.Albany.Edu> tmm33 at 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



More information about the Comp.unix.xenix mailing list