bb_daemonize should double-fork so it isn't a session leader, and hence
doesn't get a controlling tty on Linux if a tty is ever opened, similar to
how libdaemon's daemon_fork or the big start-stop-daemon does it.

For details, see http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3

Signed-off-by: Peter Korsgaard <jac...@sunsite.dk>
---
 libbb/vfork_daemon_rexec.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index a75eafb..40a82e3 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -258,6 +258,8 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
                dup2(fd, 0);
                dup2(fd, 1);
                dup2(fd, 2);
+               if (fork_or_rexec(argv))
+                       exit(EXIT_SUCCESS); /* parent */
        }
        while (fd > 2) {
                close(fd--);
-- 
1.7.6.3

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to