build: Audit for use of pipe2
commit76f1663c00d7af759ea52f25aa413e377196da2f
authorEric Blake <eblake@redhat.com>
Thu, 1 Aug 2019 15:22:10 +0000 (1 10:22 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 2 Aug 2019 20:47:38 +0000 (2 15:47 -0500)
treea70508a05c96ff485d1bee8c6015d2fb9d2ae36c
parent23d25996685ab71803dae02a8d3a98923486dfb5
build: Audit for use of pipe2

Haiku unfortunately lacks pipe2, so we have to plan for a fallback at
each site that uses it.  This also makes a good time to audit all
existing users of pipe, to see if they should be using pipe2.  The
tests fork() but don't fail because of fd leaks; and the nbd plugin
doesn't fork() but was merely using pipe2 for convenience over
multiple fcntl calls.  However, the server's quit_fd definitely needs
to be marked CLOEXEC (it's easy to use the sh plugin to show that we
are currently leaking it to children), although doing so can occur
without worrying about atomicity since it is called before threads
begin.  Finally, it's also worth updating our set_cloexec helper
function to document that we still prefer atomicity where possible.

Signed-off-by: Eric Blake <eblake@redhat.com>
common/utils/utils.c
configure.ac
plugins/nbd/nbd.c
server/quit.c
tests/test-layers.c
tests/test-streaming.c