aboutsummaryrefslogtreecommitdiff
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 a570ddbf2..2055c4b71 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)
296 } 296 }
297 297
298 if (flags & DAEMON_DEVNULL_STDIO) { 298 if (flags & DAEMON_DEVNULL_STDIO) {
299 xdup2(fd, 0); 299 if (flags & DAEMON_DEVNULL_STDIN)
300 xdup2(fd, 1); 300 xdup2(fd, 0);
301 xdup2(fd, 2); 301 if (flags & DAEMON_DEVNULL_OUTERR) {
302 xdup2(fd, 1);
303 xdup2(fd, 2);
304 }
302 } else { 305 } else {
303 /* have 0,1,2 open at least to /dev/null */ 306 /* have 0,1,2 open at least to /dev/null */
304 while ((unsigned)fd < 2) 307 while ((unsigned)fd < 2)