nonblocking I/O techniques for System V

Norman Joseph norm at oglvee.UUCP
Thu Aug 24 23:26:28 AEST 1989


>From article <17450 at bellcore.bellcore.com>, by tr at madeleine (tom reingold):
> What's the technique for nonblocking I/O for System V.  In BSD, you use
> select() which is very convenient and elegant.  What's the equivalent.
> I think I've heard that it requires several function calls.

See your system's manual page for the open() system call, and look for the
O_NDELAY flag.  According to Rochkind in _Advanced_UNIX_Programming_,
Sec. 2.6:

        When opening pipes, FIFOs, and communication-line special
        files, this flag determines whether open waits or returns
        immediately.  Subsequent reads and writes are also affected.
        [...]  O_NDELAY has no effect on ordinary files and directories.

The drawback is that, if no data is waiting, a read() will return a zero
count, just as if you had hit ^D.

You may also consider supplementing your library with Rochkind's book
(ISBN 0-13-011800-1), which contains a wealth of information on programming
with UNIX system calls.

Disclaimer: NOT a stockholder in Prentice-Hall, just a satisfied customer.
-- 
Norm Joseph - Oglevee Computer System, Inc.
  UUCP: ...!{pitt,cgh}!amanue!oglvee!norm
    /* you are not expected to understand this */



More information about the Comp.unix.wizards mailing list