125 lines
3.7 KiB
Groff
125 lines
3.7 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g2.pipe @(#)pipe 41.5 of 5/26/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} pipe 2 "" "\&"
|
|
.if \nX=1 .ds x} pipe 2 ""
|
|
.if \nX=2 .ds x} pipe 2 "" "\&"
|
|
.if \nX=3 .ds x} pipe "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4pipe\f1 \- create an interprocess channel
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
\f4#include <unistd.h>
|
|
.PP
|
|
\f4int pipe(int fildes[2]);\f1
|
|
.Op
|
|
.Op f
|
|
.SH FORTRAN SYNOPSIS
|
|
\f4integer \(**4 function pipe (fildes)\f1
|
|
.br
|
|
\f4integer \(**4 fildes (2)\f1
|
|
.Op
|
|
.SH DESCRIPTION
|
|
\f4pipe\fP
|
|
creates an \s-1I/O\s0 mechanism called a pipe and returns two file descriptors,
|
|
\f2fildes\f4[0]\f1
|
|
and
|
|
\f2fildes\f4[1]\f1.
|
|
IRIX has two distinct versions of pipe: the SVR4 version and the SVR3.2 version.
|
|
The SVR3.2 version is faster, and is generally preferred unless STREAMS
|
|
semantics are required for a specific reason.
|
|
.PP
|
|
The SVR4 version of \f4pipe\fP returns two STREAMS-based file descriptors
|
|
which are both opened for reading and writing.
|
|
The \f4O_NDELAY\f1 and \f4O_NONBLOCK\f1 flags are cleared.
|
|
A read from \f2fildes\f4[0]\f1 accesses the data written to \f2fildes\f4[1]\f1
|
|
on a first-in-first-out (\s-1FIFO\s+1) basis and a read from \f2fildes\f4[1]\f1
|
|
accesses the data written to \f2fildes\f4[0]\f1 also on a FIFO basis.
|
|
The \f4FD_CLOEXEC\f1 flag will be clear on both file descriptors.
|
|
.PP
|
|
The SVR3.2 version of \f4pipe\fP returns two non-STREAMS-based
|
|
file descriptors.
|
|
.IR Fildes [0]
|
|
is opened for reading and
|
|
.IR fildes [1]
|
|
is opened for writing.
|
|
Up to
|
|
.SM
|
|
.B PIPE_BUF
|
|
(defined in
|
|
.BR limits.h )
|
|
bytes of data are buffered by the pipe before the writing process is blocked
|
|
and guaranteed to be written atomically.
|
|
The \f4O_NDELAY\f1 and \f4O_NONBLOCK\f1 flags are cleared.
|
|
A read only file descriptor
|
|
.IR fildes [0]
|
|
accesses the data written to
|
|
.IR fildes [1]
|
|
on a first-in-first-out (\s-1FIFO\s+1) basis.
|
|
.PP
|
|
Upon successful completion \f4pipe\fP marks for update the
|
|
\f4st_atime, st_ctime\f1, and \f4st_mtime\f1 fields of the pipe.
|
|
.\".P
|
|
.\"If the Enhanced Security Utilities are installed and running, the
|
|
.\"Mandatory Access Control level of the new pipe is set to the level of the
|
|
.\"calling process.
|
|
.PP
|
|
To use the SVR4 version of \f4pipe\fP one must normally tune
|
|
the system tunable variable
|
|
\f4svr3pipe\fP to 0 (see \f4systune\fP(1M)).
|
|
Otherwise, the SVR3.2 version of \f4pipe\fP is used, with the exception of
|
|
applications linked against
|
|
.B libnsl.so
|
|
(\f3-lnsl\fP), which normally
|
|
get SVR4-style pipes by default. This can be disabled by setting the
|
|
environment variable
|
|
.B _LIBNSL_USE_SVR3_PIPE
|
|
to
|
|
.BR 1 .
|
|
In this case such applications will get SVR3.2-styl pipe semantics.
|
|
.PP
|
|
\f4pipe\fP
|
|
fails if:
|
|
.TP 15
|
|
\f4EMFILE\fP
|
|
The maximum number of file descriptors are currently open.
|
|
.TP
|
|
\f4ENFILE\fP
|
|
A file table entry could not be allocated.
|
|
.SH "SEE ALSO"
|
|
\f4sh\fP(1),
|
|
\f4systune\fP(1M),
|
|
\f4fcntl\fP(2), \f4getmsg\fP(2), \f4intro\fP(3N), \f4poll\fP(2),
|
|
\f4putmsg\fP(2), \f4read\fP(2), \f4write\fP(2), \f4popen\fP(3S),
|
|
\f4streamio\fP(7)
|
|
.SH "DIAGNOSTICS"
|
|
Upon successful completion,
|
|
a value of 0
|
|
is returned.
|
|
Otherwise, a value of \-1 is returned and
|
|
\f4errno\fP
|
|
is set to indicate the error.
|
|
.SH "NOTES"
|
|
Since a SVR4 version of pipe is bi-directional, there are two separate
|
|
flows of data.
|
|
Therefore, the size (\f4st_size\fP) returned by a call to \f4fstat\fP(2)
|
|
with argument
|
|
\f2fildes\f4[0]\f1 or
|
|
\f2fildes\f4[1]\f1
|
|
is the number of bytes available for reading from
|
|
\f2fildes\f4[0]\f1 or
|
|
\f2fildes\f4[1]\f1
|
|
respectively.
|
|
Previously, the size
|
|
(\f4st_size\fP) returned by a call to
|
|
\f4fstat\fP(\)
|
|
with argument
|
|
\f2fildes\f4[1]\f1
|
|
(the write-end) was the number of bytes available for reading from
|
|
\f2fildes\f4[0]\f1 (the read-end).
|
|
.\" @(#)pipe.2 6.2 of 9/6/83
|
|
.Ee
|