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
(section)
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!
== 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>
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)