Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.xenix Subject: Re: getc help needed, using rdchk() Summary: O_NDELAY is more efficient Message-ID: <1210@virtech.UUCP> Date: 28 Sep 89 23:54:25 GMT References: <1166@orbit.UUCP> Organization: Virtual Technologies Inc Lines: 26 In article <1166@orbit.UUCP>, vemis@pnet51.orb.mn.org (Jeff Mo) writes: > tmm33@leah.Albany.Edu (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. > > Under SCO Xenix 2.2.x and 2.3.x, a call to rdchk(file_descriptor) > will return a 1 if the process will not block on a read(), > or if it's at EOF. To use: > if (rdchk(file_des) > 0) > read(file_des, buffer, nbytes); O_NDELAY in the open() (or through an ioctl()) is preferred because it does not require the extra overhead of an extra system call (the rdchk()). In addition it is much more portable. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+