- Add close-on-exec flags where applicable, either with arguments when
opening the file or with fcntl calls. The possibility of applying the
flags atomically, when opening the file, is tested by the configure
script.
- Close the duplicated socket_write fd if fdopen in comm.c fails.
The feature test macro for POSIX.2001 is used in other source files
already, we should just use it when appropriate.
strdup() declaration is obtained by defining _XOPEN_SOURCE=500. Need (?)
to find out if there libcs that define it for POSIX.2008 but not for
X/Open.5.
We could use `extern const char *__progname` to work on musl/glibc and
BSDs, but it's not a recommended interface, and they prefer
getprogname(). In the interest of proper platform usage, use
getprogname() on BSD and program_invocation_short_name on musl/glibc.
Supporting arc4random_buf and getrandom is pretty simple.
Hasn't been tested on an actual BSD platform.