Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Named pipe
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Method of inter-process communication}} {{More citations needed|date=February 2025}} In [[computing]], a '''named pipe''' (also known as a '''[[FIFO (computing and electronics)|FIFO]]''' for its behavior) is an extension to the traditional [[pipeline (Unix)|pipe]] concept on [[Unix]] and [[Unix-like]] systems, and is one of the methods of [[inter-process communication]] (IPC). The concept is also found in [[OS/2]] and [[Microsoft Windows]], although the semantics differ substantially. A traditional pipe is "[[anonymous pipe|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]]. It is explicitly created using <code>mkfifo()</code><ref>{{cite web |url=https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkfifo.html |title=mkfifo, mkfifoat - make a FIFO special file|work=IEEE Std 1003.1-2017|publisher=[[The Open Group]]}}</ref> or <code>mknod()</code>,<ref>{{cite web |url=https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html |title=mknod, mknodat - make directory, special file, or regular file |work=IEEE Std 1003.1-2017|publisher=The Open Group}}</ref> and two separate [[Process (computing)|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: <syntaxhighlight lang="bash"> mkfifo my_pipe gzip -9 -c < my_pipe > out.gz & </syntaxhighlight> 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): <syntaxhighlight lang="bash"> mkfifo -m 0666 /tmp/namedPipe gzip -d < out.gz > /tmp/namedPipe </syntaxhighlight> Then load the uncompressed data into a [[MySQL]] table<ref name="MySQLLDI">{{cite web|url=https://dev.mysql.com/doc/refman/8.0/en/load-data.html|title=13.2.7 LOAD DATA Statement|work=MySQL 8.0 Reference Manual|publisher=[[MySQL]]|access-date=2020-05-19|archive-date=2020-06-14|archive-url=https://web.archive.org/web/20200614054038/https://dev.mysql.com/doc/refman/8.0/en/load-data.html|url-status=live}}</ref> like so: <syntaxhighlight lang="mysql"> LOAD DATA INFILE '/tmp/namedPipe' INTO TABLE tableName; </syntaxhighlight> 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 [[Input/output|I/O]] and less free space on the hard drive. [[PostgreSQL]]'s command line utility, <code>psql</code>, also supports loading data from named pipes.<ref>{{cite web|url=https://www.postgresql.org/message-id/20080327170517.GR6497%40yugib.highrise.ca|title=Re: psql and named pipes|author=Aidan Van Dyk|date=2008-03-27|work=pgsql-hackers|publisher=[[PostgreSQL]]|access-date=2020-05-19|archive-date=2022-05-20|archive-url=https://web.archive.org/web/20220520230323/https://www.postgresql.org/message-id/20080327170517.GR6497@yugib.highrise.ca|url-status=live}}</ref> == In Windows == A named pipe can be accessed much like a file. [[Windows API|Win32]] SDK functions <code>CreateFile</code>, <code>ReadFile</code>, <code>WriteFile</code> and <code>CloseHandle</code> open, read from, write to, and close a pipe, respectively. Unlike Unix, there is no [[command line interface]], except for [[PowerShell]]. 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 <code>\\.\pipe\</code> (that is, a pipe named "[[foo]]" would have a full path name of <code>\\.\pipe\foo</code>). 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]] [[Personal Computer|PC]] hardware [[virtual machine|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 β as WinDbg normally requires a serial connection to the target computer β letting [[device driver|driver]] [[Software developer|developers]] do their development and testing on a single computer). Both programs require the user to enter names in the <code>\\.\pipe\''name''</code> form. Windows NT named pipes can inherit a security context. Summary of named pipes on Microsoft Windows: * Intermachine and intramachine IPC * [[Duplex (telecommunications)#Half duplex|Half-duplex]] or [[Duplex (telecommunications)#Full duplex|full-duplex]] * [[Byte-oriented]] or [[packet-oriented]] * [[Reliability (computer networking)|Reliable]] * [[Connection-oriented communication]] * Blocking or Nonblocking read and write (choosable) * Standard device I/O handles (<code>ReadFile</code>, <code>WriteFile</code>) * [[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.<ref>{{cite web |url=https://docs.microsoft.com/en-us/dotnet/api/system.io.pipes |title=System.IO.Pipes Namespace |publisher=[[Microsoft Developer Network]]}}</ref> Named pipes can also be used as an endpoint in [[Microsoft SQL Server]].<ref>{{cite web | url=https://support.microsoft.com/en-us/help/265808/how-to-connect-to-sql-server-by-using-an-earlier-version-of-sql-server | title=How to connect to SQL Server by using an earlier version of SQL Server | date=2019-11-19 | publisher=[[Microsoft]] | access-date=2020-05-19 | archive-date=2020-07-20 | archive-url=https://web.archive.org/web/20200720014704/https://support.microsoft.com/en-us/help/265808/how-to-connect-to-sql-server-by-using-an-earlier-version-of-sql-server | url-status=live }}</ref> Named pipes are 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]] service over Named Pipes, as are the Exchange 5.5 Administrative applications. == See also == * [[Anonymous pipe]] * [[Anonymous named pipe]] * [[Unix file types]] ==References== {{Reflist}} ==External links== *[https://www.tldp.org/LDP/lpg/node15.html Linux Interprocess Communications: Named Pipes] ([[Linux Documentation Project]], 1996) *[http://www.linuxjournal.com/article/2156 Introduction to Named Pipes] ([[Linux Journal]], 1997) {{Inter-process communication}} {{DEFAULTSORT:Named Pipe}} [[Category:Inter-process communication]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Inter-process communication
(
edit
)
Template:More citations needed
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)