create an interprocess channel
int pipe(int fildes);
creates an I/O mechanism called a pipe and returns two file descriptors,
fildes and fildes.
The files associated with fildes and fildes are
streams and are both opened for reading and writing.
O_NONBLOCK flags are cleared.
A read from fildes accesses the data written to fildes
on a first-in-first-out (FIFO) basis and a read from fildes
accesses the data written to fildes also on a FIFO basis.
The FD_CLOEXEC flag will be clear on both file descriptors.
If pipe succeeds, it marks for update the
st_atime, st_ctime, and st_mtime fields of the pipe.
On success, pipe returns 0.
On failure, pipe returns -1 and sets errno to identify the error.
In the following conditions, pipe fails and sets errno to:
The maximum number of file descriptors are currently open.
A file table entry could not be allocated.
Since a pipe is bi-directional, there are two separate flows of data.
Therefore, the size (st_size) returned by a call to fstat
is the number of bytes available for reading from
Previously, the size
(st_size) returned by a call to
(the write-end) was the number of bytes available for reading from
fildes (the read-end).
Considerations for threads programming
Open file descriptors are a process resource
and available to any sibling thread;
if used concurrently, actions by one thread can interfere with
those of a sibling.
For example, data read from a pipe (destructive) by one thread is
not available to siblings.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005