_dbus_ensure_standard_fds: new function to ensure std* fds are open
authorSimon McVittie <smcv@debian.org>
Thu, 21 Jul 2016 07:23:12 +0000 (08:23 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 25 Jul 2016 10:26:01 +0000 (11:26 +0100)
commit69123a6bd2adabbaec1f770fc4573fc3ed4ceca6
treee61f5019f94061b029f90f8c98a2770b77448b18
parente3a14eb4fdb985af75cb81af81f25aafefc96c87
_dbus_ensure_standard_fds: new function to ensure std* fds are open

This function opens stdin, stdout, stderr pointing to /dev/null
if they aren't already open. Optionally, it can also replace
whatever is available on those fds with /dev/null.

To allow for use in contexts where only async-signal-safe functions
should be used, such as between fork() and a following exec(),
this function does not use conventional libdbus error handling
(which would require malloc). Instead, it sets errno and returns
an explanatory string.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-unix.h