For FIFO pipe speed I'm considering placing it inside the RAM disk called /dev/shm. I see there are some files there already:
$ ll /dev/shm
total 1536
drwxrwxrwt 2 root root 280 Oct 2 17:19 ./
drwxr-xr-x 22 root root 4840 Oct 2 05:49 ../
-rwx------ 1 rick rick 67108904 Oct 2 04:29 pulse-shm-1087740037*
-rwx------ 1 lightdm lightdm 67108904 Oct 2 04:29 pulse-shm-1609193682*
-rwx------ 1 rick rick 67108904 Oct 2 04:34 pulse-shm-2114917541*
-rwx------ 1 rick rick 67108904 Oct 2 04:29 pulse-shm-2616701246*
-rwx------ 1 rick rick 67108904 Oct 2 17:14 pulse-shm-3211887872*
-rwx------ 1 rick rick 67108904 Oct 2 17:14 pulse-shm-3411101615*
-rwx------ 1 rick rick 67108904 Oct 2 04:32 pulse-shm-3740841284*
-rwx------ 1 lightdm lightdm 67108904 Oct 2 04:29 pulse-shm-4039050064*
-rwx------ 1 rick rick 67108904 Oct 2 04:29 pulse-shm-608722223*
-rwx------ 1 rick rick 67108904 Oct 2 05:46 pulse-shm-629296834*
-rwx------ 1 rick rick 67108904 Oct 2 17:19 pulse-shm-791566179*
-rwx------ 1 lightdm lightdm 67108904 Oct 2 04:29 pulse-shm-871250926*Is it safe to assume this directory is universal on all Ubuntu systems or even better all Linux systems?
If the directory doesn't exist I'll create my pipe FIFO file in /tmp but hopefully that never happens.
Edit: With many thanks to two great answers written below I found this article: Why use named pipes on Linux
Why use named pipes?
Named pipes are used infrequently for a good reason. On Unix systems, there are almost always many ways to do pretty much the same thing. There are many ways to write to a file, read from a file, and empty a file, though named pipes have a certain efficiency going for them.
For one thing, named pipe content resides in memory rather than being written to disk. It is passed only when both ends of the pipe have been opened. And you can write to a pipe multiple times before it is opened at the other end and read.
2 Answers
For Linux, yes, it is universally available and according to documentation ( ) glibc, the standard C library for Linux expects /dev/shm to exist.
However, I'd still suggest reconsidering the design of your script or program. FIFOs and sockets tend to be placed into /var/run/appname or /tmp/ directories. A good example of that is /var/run/acpid.socket. Since those filesystems are also tmpfs just like /dev/shm, there's no performance difference.
BTW, placing FIFOs in tmpfs should not affect performance since pipes have hard-coded buffer size of 65536 bytes on Linux but can be changed via /proc/sys/fs/pipe-max-size . See
0Data travelling through FIFO special file will never hit the filesystem. This means that whether the underlying filesystem is tmpfs or ext2, the speed of the FIFO should be the same.
/dev/shm is intended for use by the POSIX shared memory implementation. For other uses, /tmp or /run would be more appropriate. If your named pipe is user-specific, using $XDG_RUNTIME_DIR from the XDG Base Directory Specification may be appropriate.