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.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index cb4dee799..ea7b475eb 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -202,7 +202,6 @@ int spawn_and_wait(char **argv)
202 return wait4pid(rc); 202 return wait4pid(rc);
203} 203}
204 204
205
206#if !BB_MMU 205#if !BB_MMU
207void forkexit_or_rexec(char **argv) 206void forkexit_or_rexec(char **argv)
208{ 207{
@@ -261,17 +260,18 @@ void bb_daemonize_or_rexec(int flags, char **argv)
261 260
262 if (!(flags & DAEMON_ONLY_SANITIZE)) { 261 if (!(flags & DAEMON_ONLY_SANITIZE)) {
263 forkexit_or_rexec(argv); 262 forkexit_or_rexec(argv);
264 /* if daemonizing, make sure we detach from stdio */ 263 /* if daemonizing, make sure we detach from stdio & ctty */
265 setsid(); 264 setsid();
266 dup2(fd, 0); 265 dup2(fd, 0);
267 dup2(fd, 1); 266 dup2(fd, 1);
268 dup2(fd, 2); 267 dup2(fd, 2);
269 } 268 }
270 if (fd > 2) 269 while (fd > 2) {
271 close(fd--); 270 close(fd--);
272 if (flags & DAEMON_CLOSE_EXTRA_FDS) 271 if (!(flags & DAEMON_CLOSE_EXTRA_FDS))
273 while (fd > 2) 272 return;
274 close(fd--); /* close everything after fd#2 */ 273 /* else close everything after fd#2 */
274 }
275} 275}
276 276
277void bb_sanitize_stdio(void) 277void bb_sanitize_stdio(void)