Named pipe
Encyclopedia
In computing
, a named pipe (also known as a FIFO
for its behavior) is an extension to the traditional pipe
concept on Unix
and Unix-like
systems, and is one of the methods of inter-process communication
. The concept is also found in Microsoft Windows
, although the semantics differ substantially. A traditional pipe is "unnamed" because it exists anonymously and persists only for as long as the process is running. A named pipe is system-persistent and exists beyond the life of the process and must be deleted once it is no longer being used. Processes generally attach to the named pipe (usually appearing as a file) to perform inter-process communication
(IPC).
For example, one can create a pipe and set up gzip 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:
mkfifo --mode=0666 /tmp/namedPipe
gzip --stdout -d file.gz > /tmp/namedPipe
Then load the uncompressed data into a MySQL
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 space on the hard drive.
PostgreSQL
's command line terminal,
communication, and they work much like sockets
, other than the usual read and write operations. Windows named pipes also support an explicit "passive" mode for server applications (compare: Unix domain socket
s). Windows 95
supports named pipe clients, Windows NT
based systems can also be servers.
The named pipe can be accessed much like a file. Win32 SDK functions such as CreateFile, ReadFile, WriteFile and CloseHandle can be used to open, read from, write to, and close a pipe. There is no command line interface like Unix.
Named pipes are not permanent and can not be created as special files on any writable filesystem, unlike in Unix, but are volatile names (freed after the last reference to them is closed) allocated in the root directory of the named pipe filesystem (NPFS), mounted under the special path \\.\pipe\ (that is, a pipe named "foo" 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
PC
hardware virtualization
tool, for instance, can expose emulated serial port
s to the host system as named pipes, and the WinDbg
kernel mode debugger
from Microsoft
supports named pipes as a transport for debugging sessions (in fact, VMware and WinDbg can be coupled together - since 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:
The .NET Framework
3.5 has added named pipe support.
Named pipes can also be used as an endpoint in Microsoft SQL Server
.
Named pipes is also a networking protocol in the Server Message Block
(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
services over Named Pipes, as are the Exchange 5.5 Administrative applications.
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...
, a named pipe (also known as a FIFO
FIFO
FIFO is an acronym for First In, First Out, an abstraction related to ways of organizing and manipulation of data relative to time and prioritization...
for its behavior) is an extension to the traditional pipe
Pipeline (Unix)
In Unix-like computer operating systems , a pipeline is the original software pipeline: a set of processes chained by their standard streams, so that the output of each process feeds directly as input to the next one. Each connection is implemented by an anonymous pipe...
concept on Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
and Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
systems, and is one of the methods of inter-process communication
Inter-process communication
In computing, Inter-process communication is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared...
. The concept is also found in Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
, although the semantics differ substantially. A traditional pipe is "unnamed" because it exists anonymously and persists only for as long as the process is running. A named pipe is system-persistent and exists beyond the life of the process and must be deleted once it is no longer being used. Processes generally attach to the named pipe (usually appearing as a file) to perform inter-process communication
Inter-process communication
In computing, Inter-process communication is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared...
(IPC).
In Unix
Instead of a conventional, unnamed, shell pipeline, a named pipeline makes use of the filesystem. 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 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:
mkfifo --mode=0666 /tmp/namedPipe
gzip --stdout -d file.gz > /tmp/namedPipe
Then load the uncompressed data into a MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...
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
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...
and less space on the hard drive.
PostgreSQL
PostgreSQL
PostgreSQL, often simply Postgres, is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, MS Windows and Mac OS X. It is released under the PostgreSQL License, which is an MIT-style license, and is thus free and open source software...
's command line terminal,
psql
, also supports loading data from named pipes.In Windows
In Windows, the design of named pipes is based towards client-serverClient-server
The client–server model of computing is a distributed application that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients. Often clients and servers communicate over a computer network on separate hardware, but both...
communication, and they work much like sockets
Internet socket
In computer networking, an Internet socket or network socket is an endpoint of a bidirectional inter-process communication flow across an Internet Protocol-based computer network, such as the Internet....
, other than the usual read and write operations. Windows named pipes also support an explicit "passive" mode for server applications (compare: Unix domain socket
Unix domain socket
A Unix domain socket or IPC socket is a data communications endpoint for exchanging data between processes executing within the same host operating system. While similar in functionality to...
s). Windows 95
Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...
supports named pipe clients, Windows NT
Windows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...
based systems can also be servers.
The named pipe can be accessed much like a file. Win32 SDK functions such as CreateFile, ReadFile, WriteFile and CloseHandle can be used to open, read from, write to, and close a pipe. There is no command line interface like Unix.
Named pipes are not permanent and can not be created as special files on any writable filesystem, unlike in Unix, but are volatile names (freed after the last reference to them is closed) allocated in the root directory of the named pipe filesystem (NPFS), mounted under the special path \\.\pipe\ (that is, a pipe named "foo" 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
VMware Workstation is a virtual machine software suite for x86 and x86-64 computers from VMware, a division of EMC Corporation, which allows users to set up multiple x86 and x86-64 virtual machines and use one or more of these virtual machines simultaneously with the hosting operating system...
PC
Personal computer
A personal computer is any general-purpose computer whose size, capabilities, and original sales price make it useful for individuals, and which is intended to be operated directly by an end-user with no intervening computer operator...
hardware virtualization
Virtual machine
A virtual machine is a "completely isolated guest operating system installation within a normal host operating system". Modern virtual machines are implemented with either software emulation or hardware virtualization or both together.-VM Definitions:A virtual machine is a software...
tool, for instance, can expose emulated serial port
Serial port
In computing, a serial port is a serial communication physical interface through which information transfers in or out one bit at a time...
s to the host system as named pipes, and the WinDbg
WinDbg
WinDbg is a multipurposed debugger for Microsoft Windows, distributed on the web by Microsoft. It can be used to debug user mode applications, drivers, and the operating system itself in kernel mode...
kernel mode debugger
Debugger
A debugger or debugging tool is a computer program that is used to test and debug other programs . The code to be examined might alternatively be running on an instruction set simulator , a technique that allows great power in its ability to halt when specific conditions are encountered but which...
from Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...
supports named pipes as a transport for debugging sessions (in fact, VMware and WinDbg can be coupled together - since WinDbg normally requires a serial connection to the target computer - letting driver
Device driver
In computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device....
developers
Software developer
A software developer is a person concerned with facets of the software development process. Their work includes researching, designing, developing, and testing software. A software developer may take part in design, computer programming, or software project management...
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 or full-duplex
- Byte-oriented or Message-oriented
- Reliable
- Blocking or Nonblocking read and write (choosable)
- Standard device I/O handles (
FileRead
,FileWrite
) - NamespaceNamespaceIn general, a namespace is a container that provides context for the identifiers it holds, and allows the disambiguation of homonym identifiers residing in different 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
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
3.5 has added named pipe support.
Named pipes can also be used as an endpoint in Microsoft SQL Server
Microsoft SQL Server
Microsoft SQL Server is a relational database server, developed by Microsoft: It is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network...
.
Named pipes is also a networking protocol in the Server Message Block
Server Message Block
In computer networking, Server Message Block , also known as Common Internet File System operates as an application-layer network protocol mainly used to provide shared access to files, printers, serial ports, and miscellaneous communications between nodes on a network. It also provides an...
(SMB) suite, based on the use of a special inter-process communication
Inter-process communication
In computing, Inter-process communication is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared...
(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
DCE/RPC
DCE/RPC, short for "Distributed Computing Environment / Remote Procedure Calls", is the remote procedure call system developed for the Distributed Computing Environment...
services over Named Pipes, as are the Exchange 5.5 Administrative applications.