Nobody On The Other End

A daemon publishes events through a FIFO. No process has opened the FIFO yet.

mkfifo("/run/app/events", 0666);
int fd = open("/run/app/events", O_WRONLY | O_NONBLOCK);
if (fd < 0) { perror("open"); return 1; }

What happens at the open call?

A

It succeeds, and the first write fails with EPIPE and raises SIGPIPE.

B

It fails immediately with ENXIO, because a write-only nonblocking open of a FIFO requires a reader to already be present.

C

It blocks until some process opens the FIFO for reading, since O_NONBLOCK only affects later read and write calls.

D

It succeeds, and writes are buffered in the kernel until a reader shows up.