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).
mkfifo foobar
# same difference
mknod foobar p
In strace
it's identical for both commands:
mknod("foobar", S_IFIFO|0666) = 0
So in terms of syscalls, mkfifo
is actually shorthand for mknod
.
The biggest difference, then, is in semantics. With mkfifo
you can create a bunch of FIFOs in one go:
mkfifo a b c
With mknod
, since you have to specify the type, it only ever accepts one argument:
# wrong:
$ mknod a b c p
mknod: invalid major device number ‘c’
# right:
mknod a p
mknod b p
mknod c p
In general, mknod
can be difficult to use correctly. So if you want to work with FIFO, stick to mkfifo
.