~/ learn/ comp-325/ cards/ A pipe with a name, and a umask interaction
1 of 9

Create the FIFO, tolerating one that is already there

Create the FIFO, tolerating one that is already there

Answer

if (mkfifo("/tmp/chan", 0666) == -1 && errno != EEXIST) { perror("mkfifo"); _exit(1); }

mkfifo returns 0 or -1. EEXIST is the one failure worth surviving — it means a previous run left the name behind. The mode 0666 is a request: the umask filters it, so with umask 022 the FIFO is created 0644.

S&K 3e ch20 §20.5; mkfifo() per POSIX.1-2024; umask interaction per Module 4

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/1d88718a-f7cc-4196-bf20-abb10cd1b197/flashcard utf-8 LF