NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO | RESTRICTIONS FOR ChorusOS
#include <unistd.h>int pipe(int fildes[2]);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
POSIX_SOCKETS
The pipe function creates a pipe, which is an object allowing unidirectional data flow, and allocates a pair of file descriptors. The first descriptor connects to the read end of the pipe, and the second connects to the write end, so that data written to fildes[1] appears on (in other words, it can be read from) fildes[0] . This allows the output of one program to be sent to another program: the source's standard output is set up to be the write end of the pipe, and the sink's standard input is set up to be the read end of the pipe. The pipe itself persists until all its associated descriptors are closed.
A pipe whose read or write end has been closed is considered widowed . Writing to this type of
pipe causes the writing process to receive a SIGPIPE
signal (see RESTRICTIONS for ChorusOS). Widowing a pipe
is the only way to deliver end-of-file to a reader:after the reader has consumed
any buffered data; reading a widowed pipe returns a zero count.
Pipes are a special case of the socketpair(2POSIX) call and are implemented as such in the system.
Upon successful creation of the pipe, 0 is returned. Otherwise, a value of -1 is returned and the errno variable is set to indicate one of the following error conditions.
Too many descriptors are active.
The system file table is full.
The fildes buffer is in an invalid area of the process's address space.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
MT-Level | Async-Signal-Safe |
Signals are handled by user mode processes only.
NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO | RESTRICTIONS FOR ChorusOS