]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/man/man2/pipe.2
xnu-3248.20.55.tar.gz
[apple/xnu.git] / bsd / man / man2 / pipe.2
index 759b9b9ef1b5ab31124183b70787ee25267a50c6..df5b9d85c902b8894bb48c67d2a9cd2a9a589758 100644 (file)
@@ -33,7 +33,7 @@
 .\"
 .\"     @(#)pipe.2     8.1 (Berkeley) 6/4/93
 .\"
 .\"
 .\"     @(#)pipe.2     8.1 (Berkeley) 6/4/93
 .\"
-.Dd June 4, 1993
+.Dd February 17, 2011
 .Dt PIPE 2
 .Os BSD 4
 .Sh NAME
 .Dt PIPE 2
 .Os BSD 4
 .Sh NAME
 .Sh SYNOPSIS
 .Fd #include <unistd.h>
 .Ft int
 .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
 .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
 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:
 .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 .
 .Pp
 A pipe whose read or write end has been closed is considered
 .Em widowed .
@@ -80,6 +82,12 @@ signal.
 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.
 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
 .Sh RETURN VALUES
 On successful creation of the pipe, zero is returned. Otherwise, 
 a value of -1 is returned and the variable
@@ -91,22 +99,26 @@ The
 .Fn pipe
 call will fail if:
 .Bl -tag -width Er
 .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 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 ,
 .El
 .Sh SEE ALSO
 .Xr sh 1 ,
-.Xr read 2 ,
-.Xr write 2 ,
 .Xr fork 2 ,
 .Xr fork 2 ,
-.Xr socketpair 2
+.Xr read 2 ,
+.Xr socketpair 2 ,
+.Xr fcntl 2 ,
+.Xr write 2
 .Sh HISTORY
 A
 .Fn pipe
 .Sh HISTORY
 A
 .Fn pipe