server: Add utility functions for setting CLOEXEC and NONBLOCK
commit8e94e84d489c6eb6cae1ad54bd65ba393ebf4884
authorEric Blake <eblake@redhat.com>
Thu, 1 Aug 2019 19:31:26 +0000 (1 14:31 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 2 Aug 2019 20:47:38 +0000 (2 15:47 -0500)
tree727a93b5aa89df725fc5d46f5e3fca545ffed65e
parentf12371c8acd658f502b0765d211686d372a31b22
server: Add utility functions for setting CLOEXEC and NONBLOCK

Upcoming patches will be setting FD_CLOEXEC and/or O_NONBLOCK on more
files; the correct way to do this requires a read-modify-write, which
is enough lines of code to be worth a helper function.  I chose the
semantics of close()ing the fd on (unlikely) failure, on the grounds
that these functions will likely be used only immediately after the fd
is created.

Signed-off-by: Eric Blake <eblake@redhat.com>
common/utils/utils.c
common/utils/utils.h