aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
committerRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
commitb0f54743e36af163ae2530c381c485bb29df13dc (patch)
treecda4cfeaae6e47fe4f14c1b566092be4da9affc4 /libbb/vfork_daemon_rexec.c
parent40514a0309939f2446f0d4ed9600cad5de396e7f (diff)
parentba88826c66411affc1da3614742b454654f7298a (diff)
downloadbusybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.gz
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.bz2
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.zip
Merge branch 'busybox' into merge
Conflicts: Makefile.flags
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r--libbb/vfork_daemon_rexec.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 5d8056bd6..6611dabfa 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -256,11 +256,19 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
256 if (!(flags & DAEMON_ONLY_SANITIZE)) { 256 if (!(flags & DAEMON_ONLY_SANITIZE)) {
257 if (fork_or_rexec(argv)) 257 if (fork_or_rexec(argv))
258 exit(EXIT_SUCCESS); /* parent */ 258 exit(EXIT_SUCCESS); /* parent */
259 /* if daemonizing, make sure we detach from stdio & ctty */ 259 /* if daemonizing, detach from stdio & ctty */
260 setsid(); 260 setsid();
261 dup2(fd, 0); 261 dup2(fd, 0);
262 dup2(fd, 1); 262 dup2(fd, 1);
263 dup2(fd, 2); 263 dup2(fd, 2);
264 if (flags & DAEMON_DOUBLE_FORK) {
265 /* On Linux, session leader can acquire ctty
266 * unknowingly, by opening a tty.
267 * Prevent this: stop being a session leader.
268 */
269 if (fork_or_rexec(argv))
270 exit(EXIT_SUCCESS); /* parent */
271 }
264 } 272 }
265 while (fd > 2) { 273 while (fd > 2) {
266 close(fd--); 274 close(fd--);