diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-23 12:12:03 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-23 12:12:03 +0000 |
commit | b0f54743e36af163ae2530c381c485bb29df13dc (patch) | |
tree | cda4cfeaae6e47fe4f14c1b566092be4da9affc4 /libbb/vfork_daemon_rexec.c | |
parent | 40514a0309939f2446f0d4ed9600cad5de396e7f (diff) | |
parent | ba88826c66411affc1da3614742b454654f7298a (diff) | |
download | busybox-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.c | 10 |
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--); |