man(1) Manual page archive


     PIPE(2)                                                   PIPE(2)

     NAME
          pipe - create an interprocess channel

     SYNOPSIS
          pipe(fildes)
          int fildes[2];

     DESCRIPTION
          The returned file descriptors are the ends of pair of
          cross-connected streams (See stream(4)). Data written via
          fildes[1] is available for reading via fildes[0] and vice
          versa.

          It is assumed that after the pipe has been set up, two (or
          more) cooperating processes (created by subsequent fork
          calls) will pass data through the pipe with read and write
          calls.  The record structure induced by write calls is main-
          tained by a pipe and is visible to a reader, provided no
          line disciplines modules have been pushed into the pipe
          stream; see write(2).

          The Shell has a syntax to set up a linear array of processes
          connected by pipes.

          Write calls on a one-ended pipe raise signal SIGPIPE.  Read
          calls on a one-ended pipe with no data in it return an end-
          of-file for the first several attempts, then raise SIGPIPE.

     SEE ALSO
          sh(1), read(2), write(2), fork(2)

     DIAGNOSTICS
          The function value zero is returned if the pipe was created;
          -1 if too many files are already open.

     BUGS
          Should too much buffering be necessary in any pipeline among
          a loop of processes, deadlock will occur.