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