In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, a named pipe (also known as a
FIFO for its behavior) is an extension to the traditional
pipe
Pipe(s), PIPE(S) or piping may refer to:
Objects
* Pipe (fluid conveyance), a hollow cylinder following certain dimension rules
** Piping, the use of pipes in industry
* Smoking pipe
** Tobacco pipe
* Half-pipe and quarter pipe, semi-circular ...
concept on
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
systems, and is one of the methods of
inter-process communication (IPC). The concept is also found in
OS/2
OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 r ...
and
Microsoft Windows, although the semantics differ substantially. A traditional pipe is "
unnamed" and lasts only as long as the process. A named pipe, however, can last as long as the system is up, beyond the life of the process. It can be deleted if no longer used. Usually a named pipe appears as a file, and generally processes attach to it for IPC.
In Unix
Instead of a conventional, unnamed, shell pipeline, a named pipeline makes use of the
filesystem
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is Computer data storage, stored and retrieved. Without a file system, data placed in a storage me ...
. It is explicitly created using
mkfifo()
or
mknod()
, and two separate
processes can access the pipe by name — one process can open it as a reader, and the other as a writer.
For example, one can create a pipe and set up
gzip
gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and i ...
to compress things piped to it:
mkfifo my_pipe
gzip -9 -c < my_pipe > out.gz &
In a separate process shell, independently, one could send the data to be compressed:
cat file > my_pipe
The named pipe can be deleted just like any file:
rm my_pipe
A named pipe can be used to transfer information from one application to another without the use of an intermediate temporary file. For example, you can pipe the output of gzip into a named pipe like so (here out.gz is from above example but it can be any gz):
mkfifo -m 0666 /tmp/namedPipe
gzip -d < out.gz > /tmp/namedPipe
Then load the uncompressed data into a
MySQL
MySQL () is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A relational database ...
table
like so:
LOAD DATA INFILE '/tmp/namedPipe' INTO TABLE tableName;
Without this named pipe one would need to write out the entire uncompressed version of file.gz before loading it into MySQL. Writing the temporary file is both time consuming and results in more
I/O and less free space on the hard drive.
PostgreSQL's command line utility,
psql
, also supports loading data from named pipes.
In Windows
A named pipe can be accessed much like a file.
Win32
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations th ...
SDK functions
CreateFile
,
ReadFile
,
WriteFile
and
CloseHandle
open, read from, write to, and close a pipe, respectively. Unlike Unix, there is no
command line interface, except for
PowerShell
PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-sou ...
.
Named pipes cannot be created as files within a normal filesystem, unlike in Unix. Also unlike their Unix counterparts, named pipes are volatile (removed after the last reference to them is closed). Every pipe is placed in the root directory of the named pipe filesystem (NPFS), mounted under the special path
\\.\pipe\
(that is, a pipe named "
foo
The terms foobar (), foo, bar, baz, and others are used as metasyntactic variables and placeholder names in computer programming or computer-related documentation. - Etymology of "Foo" They have been used to name entities such as variables, f ...
" would have a full path name of
\\.\pipe\foo
). Anonymous pipes used in pipelining are actually named pipes with a random name.
They are very rarely seen by users, but there are notable exceptions. The
VMware Workstation
VMware Workstation Pro (known as VMware Workstation until release of VMware Workstation 12 in 2015) is a hosted (Type 2) hypervisor that runs on x64 versions of Windows and Linux operating systemshttps://kb.vmware.com/selfservice/microsites/sear ...
PC hardware
virtualization
In computing, virtualization or virtualisation (sometimes abbreviated v12n, a numeronym) is the act of creating a virtual (rather than actual) version of something at the same abstraction level, including virtual computer hardware platforms, stor ...
tool, for instance, can expose emulated
serial port
In computing, a serial port is a serial communication interface through which information transfers in or out sequentially one bit at a time. This is in contrast to a parallel port, which communicates multiple bits simultaneously in parallel. ...
s to the host system as named pipes, and the
WinDbg
WinDbg is a multipurpose debugger for the Microsoft Windows computer operating system, distributed by Microsoft. Debugging is the process of finding and resolving errors in a system; in computing it also includes exploring the internal operation ...
kernel mode
debugger
A debugger or debugging tool is a computer program used to test and debug other programs (the "target" program). The main use of a debugger is to run the target program under controlled conditions that permit the programmer to track its executi ...
from
Microsoft
Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washin ...
supports named pipes as a transport for debugging sessions (in fact, VMware and WinDbg can be coupled together – as WinDbg normally requires a serial connection to the target computer – letting
driver developers do their development and testing on a single computer). Both programs require the user to enter names in the
\\.\pipe\''name''
form.
Windows NT named pipes can inherit a security context.
Summary of named pipes on Microsoft Windows:
* Intermachine and intramachine IPC
*
Half-duplex
A duplex communication system is a point-to-point system composed of two or more connected parties or devices that can communicate with one another in both directions. Duplex systems are employed in many communications networks, either to allow ...
or
full-duplex
A duplex communication system is a point-to-point system composed of two or more connected parties or devices that can communicate with one another in both directions. Duplex systems are employed in many communications networks, either to allow ...
*
Byte-oriented
Byte-oriented framing protocol is "a communications protocol in which full bytes are used as control codes. Also known as character-oriented protocol." For example UART communication is byte-oriented.
The term "character-oriented" is deprecated, ...
or
packet-oriented
In telecommunications, packet switching is a method of grouping data into '' packets'' that are transmitted over a digital network. Packets are made of a header and a payload. Data in the header is used by networking hardware to direct the pack ...
*
Reliable
*
Connection-oriented communication
Connection-oriented communication is a network communication mode in telecommunications and computer networking, where a communication session or a semi-permanent connection is established before any useful data can be transferred. The establishe ...
* Blocking or Nonblocking read and write (choosable)
* Standard device I/O handles (
ReadFile
,
WriteFile
)
*
Namespace
In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.
Namespaces ...
used to create handles
* Inefficient WAN traffic (explicit data transfer request, unlike e.g. TCP/IP sliding window, etc.)
* Peekable reads (read without removing from pipe's input buffer)
The
.NET Framework
The .NET Framework (pronounced as "''dot net"'') is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until bein ...
3.5 has added named pipe support.
Named pipes can also be used as an endpoint in
Microsoft SQL Server
Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which ...
.
Named pipes are also a networking protocol in the
Server Message Block
Server Message Block (SMB) is a communication protocol originally developed in 1983 by Barry A. Feigenbaum at IBM and intended to provide shared access to files and printers across nodes on a network of systems running IBM's OS/2. It also provide ...
(SMB) suite, based on the use of a special
inter-process communication (IPC) share. SMB's IPC can seamlessly and transparently pass the authentication context of the user across to Named Pipes. Windows NT's entire
NT Domain protocol suite of services are implemented as
DCE/RPC service over Named Pipes, as are the Exchange 5.5 Administrative applications.
See also
*
Anonymous pipe
In computer science, an anonymous pipe is a simplex 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 par ...
*
Anonymous named pipe
*
Unix file types The seven standard Unix file types are ''regular'', ''directory'', ''symbolic link'', ''FIFO special'', ''block special'', ''character special'', and ''socket'' as defined by POSIX. Different OS-specific implementations allow more types than what PO ...
References
External links
Linux Interprocess Communications: Named Pipes(
Linux Documentation Project
The Linux Documentation Project (LDP) is a dormant an all-volunteer project that maintains a large collection of GNU and Linux-related documentation and publishes the collection online. It began as a way for hackers to share their documentation wi ...
, 1996)
Introduction to Named Pipes(
Linux Journal, 1997)
{{DEFAULTSORT:Named Pipe
Inter-process communication