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 3845c0892..dad50ddb9 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -301,9 +301,12 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
301 } 301 }
302 302
303 if (flags & DAEMON_DEVNULL_STDIO) { 303 if (flags & DAEMON_DEVNULL_STDIO) {
304 xdup2(fd, 0); 304 if (flags & DAEMON_DEVNULL_STDIN)
305 xdup2(fd, 1); 305 xdup2(fd, 0);
306 xdup2(fd, 2); 306 if (flags & DAEMON_DEVNULL_OUTERR) {
307 xdup2(fd, 1);
308 xdup2(fd, 2);
309 }
307 } else { 310 } else {
308 /* have 0,1,2 open at least to /dev/null */ 311 /* have 0,1,2 open at least to /dev/null */
309 while ((unsigned)fd < 2) 312 while ((unsigned)fd < 2)