Named Pipes (FIFOs)

Command lines are formed regularly under UNIX to pipe information from one process to another. These pipes are anonymous. When unrelated processes want to pipe information, they usually require the help of a named pipe. Because pipes process information on a first-in, first-out basis, they are also known as FIFOs.

A FIFO can be created from a C/C++ program using the mkfifo(2) function. The function synopsis is as follows:

#include <sys/types.h>
#include <sys/stat.h>

int mkfifo(const char *path, mode_t mode);

The FIFO is created with the pathname path with permissions specified by the argument mode. The permission bits in mode are subject to the current umask(2) value in effect.

The function mkfifo(2) returns 0 when successful ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.