Re: s6-rc:

From: Laurent Bercot <>
Date: Sat, 28 Jan 2017 10:47:40 +0000

>By the way, is the blocking behavior of fifos part of POSIX ?

  It's Complicated (tm).

  Roughly yes. The important parts, i.e. how open(fifo, O_WRONLY) and
write() should behave when there's no reader, are specified by POSIX, so
the behaviour is perfectly safe. For our use case of using fifos as
synchronization points, you can rest assured that things will work.

  The problematic parts of fifos are what happens when there are
multiple readers (which is a programming error anyway), and what happens
to the reader when the last writer closes and another reopens. The
is a real question that I (and djb before me) have encountered, and the
behaviour is different on many OSes and cannot be relied on. So be
if you play with fifos; when I need fifos, as in the ftrigr library, I
always open the fifo for writing as well as for reading (and do nothing
with the writing fd), guaranteeing that a reader always has at least one
writer, in which case everything happens portably.

  (Another issue is what exactly happens when the last writer closes and
the reader is using an asynchronous event loop. On some systems the
gets POLLIN, on others POLLHUP, and on others POLLIN|POLLHUP. Making
a reader always has a writer also avoids that problem.)

Received on Sat Jan 28 2017 - 10:47:40 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC