fbpx
Wikipedia

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 (IPC). The concept is also found in OS/2 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 edit

Instead of a conventional, unnamed, shell pipeline, a named pipeline makes use of the filesystem. It is explicitly created using mkfifo()[1] or mknod(),[2] 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 (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 table[3] 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.[4]

In Windows edit

A named pipe can be accessed much like a file. Win32 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.

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" 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 – 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:

The .NET Framework 3.5 has added named pipe support.[5]

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

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 edit

References edit

  1. ^ "mkfifo, mkfifoat - make a FIFO special file". IEEE Std 1003.1-2017. The Open Group.
  2. ^ "mknod, mknodat - make directory, special file, or regular file". IEEE Std 1003.1-2017. The Open Group.
  3. ^ "13.2.7 LOAD DATA Statement". MySQL 8.0 Reference Manual. MySQL.
  4. ^ Aidan Van Dyk (2008-03-27). "Re: psql and named pipes". pgsql-hackers. PostgreSQL.
  5. ^ "System.IO.Pipes Namespace". Microsoft Developer Network.
  6. ^ "How to connect to SQL Server by using an earlier version of SQL Server". Microsoft. 2019-11-19. Retrieved 2020-05-19.

External links edit

named, pipe, computing, named, pipe, also, known, fifo, behavior, extension, traditional, pipe, concept, unix, unix, like, systems, methods, inter, process, communication, concept, also, found, microsoft, windows, although, semantics, differ, substantially, tr. 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 IPC The concept is also found in OS 2 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 Contents 1 In Unix 2 In Windows 3 See also 4 References 5 External linksIn Unix editInstead of a conventional unnamed shell pipeline a named pipeline makes use of the filesystem It is explicitly created using mkfifo 1 or mknod 2 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 lt my pipe gt out gz amp In a separate process shell independently one could send the data to be compressed cat file gt 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 lt out gz gt tmp namedPipe Then load the uncompressed data into a MySQL table 3 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 4 In Windows editA named pipe can be accessed much like a file Win32 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 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 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 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 i name i 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 packet oriented Reliable Connection oriented communication Blocking or Nonblocking read and write choosable Standard device I O handles ReadFile WriteFile 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 5 Named pipes can also be used as an endpoint in Microsoft SQL Server 6 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 editAnonymous pipe Anonymous named pipe Unix file typesReferences edit mkfifo mkfifoat make a FIFO special file IEEE Std 1003 1 2017 The Open Group mknod mknodat make directory special file or regular file IEEE Std 1003 1 2017 The Open Group 13 2 7 LOAD DATA Statement MySQL 8 0 Reference Manual MySQL Aidan Van Dyk 2008 03 27 Re psql and named pipes pgsql hackers PostgreSQL System IO Pipes Namespace Microsoft Developer Network How to connect to SQL Server by using an earlier version of SQL Server Microsoft 2019 11 19 Retrieved 2020 05 19 External links editLinux Interprocess Communications Named Pipes Linux Documentation Project 1996 Introduction to Named Pipes Linux Journal 1997 Retrieved from https en wikipedia org w index php title Named pipe amp oldid 1082902383, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.