Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pipe(2) [ultrix man page]

pipe(2) 							System Calls Manual							   pipe(2)

Name
       pipe - create an interprocess channel

Syntax
       include <limits.h> /*Definition of PIPE_MAX*/
       pipe(fildes)
       int fildes[2];

Arguments
       fildes	 Passing an address as an array of two integers into the system call.

Description
       The system call creates an I/O mechanism called a pipe.	The file descriptors returned can be used in and operations.  Their integer values
       will be the two lowest available at the time of the function call.  The O_NONBLOCK and FD_CLOEXEC flags will be clear on both file descrip-
       tors.

       When the pipe is written using the descriptor fildes[1], up to PIPE_MAX bytes of data are buffered before the writing process is suspended.
       A read using the descriptor fildes[0] picks up the data.

       It is assumed that after the pipe has been set up, two (or more) cooperating processes (created by subsequent calls) pass data through  the
       pipe with and calls.

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

       For further information on how and calls behave with pipes, see the and reference pages.

       A signal is generated if a write on a pipe with only one end is attempted.

Restrictions
       Should more than 4096 bytes be necessary in any pipe among a loop of processes, deadlock may occur.

       The  underlying	implementation	of  pipes is no longer socket based, but rather implemented through the file system.  Any application that
       needs socket functionality from pipes should use the system call.

Return Values
       The function value zero is returned if the pipe was created; -1 if an error occurred.

Diagnostics
       The call fails if:

       [EMFILE]       Too many descriptors are active.

       [ENFILE]       The system file table is full.

       [EFAULT]       The fildes buffer is in an invalid area of the process's address space.

Environment
       Differs from the System V definition in that ENFILE is not a possible error condition.

See Also
       sh(1), fork(2), read(2), socketpair(2), write(2)

																	   pipe(2)

Check Out this Related Man Page

pipe(2) 							System Calls Manual							   pipe(2)

NAME
pipe - Creates an interprocess channel SYNOPSIS
#include <unistd.h> int pipe ( int filedes[2] ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: pipe(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the address of an array of two integers into which the new file descriptors are placed. DESCRIPTION
The pipe() function creates a unidirectional interprocess channel called a pipe, and returns two file descriptors, filedes[0] and filedes[1]. The file descriptor specified by the filedes[0] parameter is opened for reading and the file descriptor specified by the filedes[1] parameter is opened for writing. Their integer values will be the two lowest available at the time of the call to the pipe() function. A process has the pipe open for reading if it has a file descriptor open that refers to the read end, filedes[0]. A process has the pipe open for writing if it has a file descriptor open that refers to the write end, filedes[1]. A read on file descriptor filedes[0] accesses the data written to filedes[1] on a first-in, first-out (FIFO) basis. System V Compatibility The pipe() function creates an interprocess channel called a pipe and returns two file descriptors, filedes[0] and filedes[1]. Both file descriptors are STREAMS based and are bidirectional. Data written on filedes[0] appears on filedes[1] and vice versa. Data is read in a first-in, first-out (FIFO) basis. Under both behaviors, the O_NONBLOCK and the FD_CLOEXC flags are set clear on both file descriptors. (The fcntl() function can be used to set the O_NONBLOCK flag.) Upon successful completion, the pipe() function marks the st_atime, st_ctime and st_mtime fields of the pipe for update. NOTES
When a read or write system call on a pipe is interrupted by a signal and no bytes have been transferred through the pipe, the read or write system call returns a -1 and errno is set to [EINTR]. This behavior is different from previous releases, when both system calls either restarted the transfer or caused errno to be set to [EINTR], depending on the setting of the SA_RESTART flag for the interrupting signal. As a result of this change, applications must now either handle the [EINTR] return or block any expected signals for the duration of the read or write operation. [Tru64 UNIX] When compiled in the X/Open UNIX environment, calls to the pipe() function are internally renamed by prepending _E to the function name. When you are debugging a module that includes the pipe() function and for which _XOPEN_SOURCE_EXTENDED has been defined, use _Epipe to refer to the pipe() call. See standards(5) for further information. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. If the pipe() function fails, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the pipe() function fails, errno may be set to one of the following values: The filedes parameter is an invalid address. A read() or a write() on a pipe is interrupted by a signal and no bytes have been transferred through the pipe. More than OPEN_MAX-2 file descriptors are already opened by this process. [Tru64 UNIX] More than getdtablesize(2) file descriptors are already opened by this process. The system file table is full, or the device containing pipes has no free i-nodes. [Tru64 UNIX] The system was unable to allocate kernel memory for more file descrip- tors. RELATED INFORMATION
Commands: sh(1) Functions: fcntl(2), getmsg(2), poll(2), putmsg(2), read(2), select(2), write(2), getdtablesize(2) Standards: standards(5) delim off pipe(2)
Man Page