Why does a named pipe not get deleted after system restart

fifopipe

As far as I understand, named pipes are not written to disk but are stored in memory. Here's how I created a named pipe –

$ mkfifo pipe21
$ grep "simple" SimpleDoc.txt > pipe21 &
[1] 2775
$ cat pipe21
Very simple doc that contains plaintext. 
[1]+  Done                    grep --color=auto "simple" SimpleDoc.txt > pipe21

After this, I restarted my system. However, even after the restart, I see pipe21 in my current directory. Why is that?

Best Answer

No they're written to disk. The command mkfifo pipe21 creates the corresponding device on your filesystem. Often times these devices are kept under /dev but named pipes (aka. FIFOS) don't necessarily have to be kept in this directory.

excerpt from wikipedia article

The named pipe can be deleted just like any file:
$ rm my_pipe

Example

Make a FIFO:

$ pwd
/home/saml

$ mkfifo pipe21

Check out the FIFO device:

$ ls -l | grep pipe
prw-rw-r--   1 saml saml        0 Jul 24 12:22 pipe21

$ file pipe21 
pipe21: fifo (named pipe)

Delete the device:

$ rm pipe21 

$ ls -l | grep pipe

References