PIPE(3)                                                   PIPE(3)

     NAME
          pipe - create an interprocess channel

     SYNOPSIS
          #include <u.h>
          #include <libc.h>

          int pipe(int fd[2])

     DESCRIPTION
          Pipe creates a buffered channel for interprocess I/O commu-
          nication.  Two file descriptors are returned in fd. Data
          written to fd[1] is available for reading from fd[0] and
          data written to fd[0] is available for reading from fd[1].

          After the pipe has been established, cooperating processes
          created by subsequent fork(2) calls may pass data through
          the pipe with read and write calls.

          When all the data has been read from a pipe and the writer
          has closed the pipe or exited, read(3) will return 0 bytes.
          Writes to a pipe with no reader will generate a note sys:
          write on closed pipe.

     SOURCE
          /usr/local/plan9/src/lib9/pipe.c

     SEE ALSO
          intro(3), read(3)

     DIAGNOSTICS
          Sets errstr.

     BUGS
          If a read or a write of a pipe is interrupted, some unknown
          number of bytes may have been transferred.

          Pipe is a macro defined as p9pipe to avoid name conflicts
          with Unix's pipe system call.

          Unix pipes are not guaranteed to be bidirectional.  In order
          to ensure a bidirectional channel, p9pipe creates Unix
          domain sockets via the socketpair(2) instead of Unix pipes.

          The implementation of pipes as Unix domain sockets causes
          problems with some Unix implementations of /dev/fd, Unix's
          dup device.  If a Unix domain socket is open as file
          descriptor 0, some implementations disallow the opening of
          /dev/fd/0; instead one must connect(2) to it.  If this func-
          tionality is important (as it is for rc(1)), one must #undef

     Page 1                       Plan 9            (printed 12/22/24)

     PIPE(3)                                                   PIPE(3)

          pipe and fall back on the (possibly unidirectional) Unix
          pipes.

     Page 2                       Plan 9            (printed 12/22/24)