aboutsummaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-04 23:04:17 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-04 23:04:17 +0200
commitb182e9ad6011909fdb76358431d23d195febaf54 (patch)
tree650b66e06387f8b0f7fe054a53150809aede7701 /debianutils
parent692eeb81a4c54d7d8bf0d2e370c12762b2a16ff7 (diff)
downloadbusybox-b182e9ad6011909fdb76358431d23d195febaf54.tar.gz
libbb: use _exit, not exit, in bb_daemonize_or_rexec()
By the time we reach exit in parent, child already exited or execed. We should not re-run libc cleanup code. While at it, introduce bb_daemon_helper() and add a few comments. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/start_stop_daemon.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 9d60b2c7f..07c104baa 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -516,6 +516,11 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
/* DAEMON_DEVNULL_STDIO is superfluous -
* it's always done by bb_daemonize() */
#else
+ /* Daemons usually call bb_daemonize_or_rexec(), but SSD can do
+ * without: SSD is not itself a daemon, it _execs_ a daemon.
+ * The usual NOMMU problem of "child can't run indefinitely,
+ * it must exec" does not bite us: we exec anyway.
+ */
pid_t pid = xvfork();
if (pid != 0) {
/* parent */
@@ -525,12 +530,8 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
}
/* Child */
setsid(); /* detach from controlling tty */
- /* Redirect stdio to /dev/null, close extra FDs.
- * We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
- bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO
- + DAEMON_CLOSE_EXTRA_FDS
- + DAEMON_ONLY_SANITIZE,
- NULL /* argv, unused */ );
+ /* Redirect stdio to /dev/null, close extra FDs */
+ bb_daemon_helper(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS);
#endif
}
if (opt & OPT_MAKEPID) {