I've used the mkfifo <file>
command to create named FIFOs, where one process writes to the file, and another process reads from the file.
Now, I know the mknod
command is able to create named pipes. Are these named pipes equivalent to the FIFOs created by mkfifo
, or do they have different features?
Best Answer
Yes, it's equivalent, but obviously only if you tell
mknod
to actually create a FIFO, and not a block or character device (rarely done these days as devtmpfs/udev does it for you).In
strace
it's identical for both commands:So in terms of syscalls,
mkfifo
is actually shorthand formknod
.The biggest difference, then, is in semantics. With
mkfifo
you can create a bunch of FIFOs in one go:With
mknod
, since you have to specify the type, it only ever accepts one argument:In general,
mknod
can be difficult to use correctly. So if you want to work with FIFO, stick tomkfifo
.