Named pipe

Named pipe

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).

Contents

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 table[1] 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, psql, also supports loading data from named pipes.[2]

In Windows

In Windows, the design of named pipes is based towards client-server 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 sockets). 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 ports 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:

  • 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)
  • Namespace 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 3.5 has added named pipe support.[3]

Named pipes can also be used as an endpoint in Microsoft SQL Server.[4]

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.

See also

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Named Pipe —   [dt. »benannte Röhre«] die, eine spezielle Pipe zur Verbindung zweier Prozesse. Sie hat einen Namen, fungiert als Puffer zwischen den Prozessen und funktioniert fast wie eine Datei. Dabei schreibt ein Prozess Daten in die Pipe, und ein anderer… …   Universal-Lexikon

  • Named Pipe — Die Pipe (englisch für Rohr, Röhre) bezeichnet einen gepufferten uni oder bidirektionalen Datenstrom zwischen zwei Prozessen nach dem „First In – First Out“ Prinzip. Das heißt vereinfacht, dass die Ausgabe eines Prozesses (ein Programm in… …   Deutsch Wikipedia

  • named pipe —    A communications API used by applications running on a network. Named pipes provide connection oriented messaging between a client and a server using routines similar to those used in normal operations for opening, reading, and writing to… …   Dictionary of networking

  • named pipe — noun An extension to the anonymous pipe concept on Unix and Unix like systems, used for interprocess communication. See Also: anonymous pipe …   Wiktionary

  • Named Pipe — Kommunikationskanal (meist realisiert durch ein von zwei Prozesse zugreifbares File) zwischen zwei Applikationen, die u.U. auf verschiedenen Systemen laufen können …   Acronyms

  • Named Pipe — Kommunikationskanal (meist realisiert durch ein von zwei Prozesse zugreifbares File) zwischen zwei Applikationen, die u.U. auf verschiedenen Systemen laufen können …   Acronyms von A bis Z

  • Pipe (Informatik) — Die Pipe (englisch für Rohr, Röhre) bezeichnet einen gepufferten uni oder bidirektionalen Datenstrom zwischen zwei Prozessen nach dem „FIFO“ (First In First Out) Prinzip. Das heißt vereinfacht, dass die Ausgabe eines Prozesses (ein Programm in… …   Deutsch Wikipedia

  • Pipe (Computer) — Die Pipe (englisch für Rohr, Röhre) bezeichnet einen gepufferten uni oder bidirektionalen Datenstrom zwischen zwei Prozessen nach dem „First In – First Out“ Prinzip. Das heißt vereinfacht, dass die Ausgabe eines Prozesses (ein Programm in… …   Deutsch Wikipedia

  • pipe —    A section of memory that can be used by a program or a command to pass information to a second command for processing. The information is stored in a firstin first out basis and is not altered during transmission. A pipe is opened like a file… …   Dictionary of networking

  • Pipe (homonymie) — Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom. Sur les autres projets Wikimedia : « Pipe (homonymie) », sur le Wiktionnaire (dictionnaire universel) Une pipe est un objet servant à fumer …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”