[comp.unix.xenix] getc help needed, using rdchk

vemis@pnet51.orb.mn.org (Jeff Mo) (09/28/89)

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);

Jeff Mo, Vision-Ease MIS department, Optifacts division.  St. Cloud, MN, USA

UUCP: {amdahl!bungia, uunet!rosevax, chinet, killer}!orbit!pnet51!vemis
ARPA: crash!orbit!pnet51!vemis@nosc.mil
INET: vemis@pnet51.cts.com

cpcahil@virtech.UUCP (Conor P. Cahill) (09/29/89)

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     |
+-----------------------------------------------------------------------+