aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-05-27 11:56:52 +0100
committerRon Yorston <rmy@pobox.com>2019-05-27 11:56:52 +0100
commita61949401890cbb33a9d6c4571b51c53460ad438 (patch)
tree64dedaddb89896d5b1670a421af123670ca2120b /libbb/vfork_daemon_rexec.c
parent03a7b173605a890e1db5177ecd5b8dd591081c41 (diff)
parentbcb1fc3e6ca6fe902610f507eaf9b0b58a5c583a (diff)
downloadbusybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.tar.gz
busybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.tar.bz2
busybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r--libbb/vfork_daemon_rexec.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 2d497d754..26e1776a4 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -268,12 +268,6 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
268 if (flags & DAEMON_CHDIR_ROOT) 268 if (flags & DAEMON_CHDIR_ROOT)
269 xchdir("/"); 269 xchdir("/");
270 270
271 if (flags & DAEMON_DEVNULL_STDIO) {
272 close(0);
273 close(1);
274 close(2);
275 }
276
277 fd = open(bb_dev_null, O_RDWR); 271 fd = open(bb_dev_null, O_RDWR);
278 if (fd < 0) { 272 if (fd < 0) {
279 /* NB: we can be called as bb_sanitize_stdio() from init 273 /* NB: we can be called as bb_sanitize_stdio() from init
@@ -283,8 +277,15 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
283 fd = xopen("/", O_RDONLY); /* don't believe this can fail */ 277 fd = xopen("/", O_RDONLY); /* don't believe this can fail */
284 } 278 }
285 279
286 while ((unsigned)fd < 2) 280 if (flags & DAEMON_DEVNULL_STDIO) {
287 fd = dup(fd); /* have 0,1,2 open at least to /dev/null */ 281 xdup2(fd, 0);
282 xdup2(fd, 1);
283 xdup2(fd, 2);
284 } else {
285 /* have 0,1,2 open at least to /dev/null */
286 while ((unsigned)fd < 2)
287 fd = dup(fd);
288 }
288 289
289 if (!(flags & DAEMON_ONLY_SANITIZE)) { 290 if (!(flags & DAEMON_ONLY_SANITIZE)) {
290 291