pipe()

create a pipe 

Function


SYNOPSIS

#include <unistd.h>

int pipe(int fildes[2]);


DESCRIPTION

The pipe() function creates a pipe and places two file descriptors, one each into the argument fildes[0] and fildes[1], that refer to open file descriptions for the read and write ends of the pipe. Their integer values are the two lowest available at the time of the pipe() call. The O_NONBLOCK and FD_CLOEXEC flags are clear on both file descriptors; the fcntl() function can be used to set both these flags.

Data can be written to the file descriptor fildes[1] and read from the file descriptor fildes[0]. A read on the file descriptor fildes[0] accesses data written to file descriptor fildes[1] on a first-in-first-out basis.

A process has the pipe open for reading if it has a file descriptor open that refers to the read end, fildes[0]. Correspondingly, a process has the pipe open for writing if it has a file descriptor open that refers to the write end, fildes[1].

Upon successful completion, pipe() marks for update the st_atime, st_ctime, and st_mtime fields of the pipe.


PARAMETERS

fildes 

Is the array of file descriptors corresponding to the open pipe.


RETURN VALUES

If successful, pipe() returns a value of zero, and fills in fildes as described above. On failure, it returns a value of -1 and sets errno to one of the following:

EFAULT 

The fildes parameter is not a valid pointer.

EMFILE 

This process is already using more than OPEN_MAX-2 file descriptors.

ENFILE 

The number of simultaneously open files in the system exceeds a system-imposed limit.


CONFORMANCE

POSIX.1 (1996).


MULTITHREAD SAFETY LEVEL

Async-signal-safe.


PORTING ISSUES

Unlike some UNIX implementations, Windows only supports unidirectional pipes.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
fcntl(), open(), read(), write()


PTC MKS Toolkit 10.4 Documentation Build 39.