.\"
.\" @(#)pipe.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd February 17, 2011
.Dt PIPE 2
.Os BSD 4
.Sh NAME
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
-.Fn pipe "int *fildes"
+.Fo pipe
+.Fa "int fildes[2]"
+.Fc
.Sh DESCRIPTION
The
.Fn pipe
function
creates a
-.Em pipe ,
-which is an object allowing
-unidirectional data flow,
+.Em pipe
+(an object that allows unidirectional data flow)
and allocates a pair of file descriptors.
The first descriptor connects to the
.Em read end
-of the pipe,
-and the second connects to the
-.Em write end ,
-so that data written to
+of the pipe;
+the second connects to the
+.Em write end .
+.Pp
+Data written to
.Fa fildes[1]
appears on (i.e., can be read from)
.Fa 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.
+the source's standard output is set up
+to be the write end of the pipe;
+the sink's standard input is set up
+to be the read end of the pipe.
+The pipe itself persists
+until all of its associated descriptors are closed.
.Pp
A pipe whose read or write end has been closed is considered
.Em widowed .
Widowing a pipe is the only way to deliver end-of-file to a reader:
after the reader consumes any buffered data, reading a widowed pipe
returns a zero count.
+.Pp
+The generation of the
+.Dv SIGPIPE
+signal can be suppressed using the
+.Dv F_SETNOSIGPIPE
+fcntl command.
.Sh RETURN VALUES
On successful creation of the pipe, zero is returned. Otherwise,
a value of -1 is returned and the variable
.Fn pipe
call will fail if:
.Bl -tag -width Er
-.It Bq Er EMFILE
-Too many descriptors are active.
-.It Bq Er ENFILE
-The system file table is full.
+.\" ===========
.It Bq Er EFAULT
The
.Fa fildes
buffer is in an invalid area of the process's address
space.
+.\" ===========
+.It Bq Er EMFILE
+Too many descriptors are active.
+.\" ===========
+.It Bq Er ENFILE
+The system file table is full.
.El
.Sh SEE ALSO
.Xr sh 1 ,
-.Xr read 2 ,
-.Xr write 2 ,
.Xr fork 2 ,
-.Xr socketpair 2
+.Xr read 2 ,
+.Xr socketpair 2 ,
+.Xr fcntl 2 ,
+.Xr write 2
.Sh HISTORY
A
.Fn pipe