In
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
, an anonymous pipe is a
simplex
In geometry, a simplex (plural: simplexes or simplices) is a generalization of the notion of a triangle or tetrahedron to arbitrary dimensions. The simplex is so-named because it represents the simplest possible polytope in any given dimension. ...
FIFO communication channel that may be used for one-way
interprocess communication (IPC). An implementation is often integrated into the
operating system's file
IO subsystem. Typically a parent program opens anonymous pipes, and creates a new process that inherits the other ends of the pipes, or creates several new processes and arranges them in a
pipeline.
Full-duplex (two-way) communication normally requires two anonymous pipes.
Pipelines are supported in most popular operating systems, from
Unix and
DOS onwards, and are created using the "
,
" character in many shells.
Unix
Pipelines are an important part of many traditional
Unix applications and support for them is well integrated into most
Unix-like operating systems. Pipes are created using the
pipe
system call, which creates a new pipe and returns a pair of
file descriptor
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically have ...
s referring to the read and write ends of the pipe. Many traditional Unix programs are designed as
filters to work with pipes.
Microsoft Windows
Like many other device IO and IPC facilities in the
Windows API, anonymous pipes are created and configured with API functions that are specific to the IO facility. In this case
CreatePipe
is used to create an anonymous pipe with separate handles for the read and write ends of the pipe. Read and write IO operations on the pipe are performed with the standard IO facility API functions
ReadFile
and
WriteFile
.
On
Microsoft Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
, reads and writes to anonymous pipes are always blocking.
In other words, a read from an empty pipe will cause the calling thread to wait until at least one byte becomes available or an
end-of-file is received as a result of the write handle of the pipe being closed. Likewise, a write to a full pipe will cause the calling thread to wait until space becomes available to store the data being written. Reads may return with fewer than the number of bytes requested (also called a ''short read'').
New processes can inherit handles to anonymous pipes in the creation process.
See also
*
Named pipe
*
Anonymous named pipe
In computing, process substitution is a form of inter-process communication that allows the input or output of a command to appear as a file. The command is substituted in-line, where a file name would normally occur, by the command shell. This all ...
*
Pipeline (Unix)
References
* Hart, Johnson M. ''Windows System Programming, Third Edition.'' Addison-Wesley, 2005.
*
Notes
{{Inter-process communication
Inter-process communication