summaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r--libbb/vfork_daemon_rexec.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index a570ddb..2055c4b 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -296,9 +296,12 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
}
if (flags & DAEMON_DEVNULL_STDIO) {
- xdup2(fd, 0);
- xdup2(fd, 1);
- xdup2(fd, 2);
+ if (flags & DAEMON_DEVNULL_STDIN)
+ xdup2(fd, 0);
+ if (flags & DAEMON_DEVNULL_OUTERR) {
+ xdup2(fd, 1);
+ xdup2(fd, 2);
+ }
} else {
/* have 0,1,2 open at least to /dev/null */
while ((unsigned)fd < 2)