Daemons detach atomically to avoid having to wait
Tests that start daemons have to "wait" for them to start. This commit makes Heimdal daemons prep to detach (when requested) by forking early, then having the child signal readiness to the parent when the child really is ready. The parent exits only which the child is ready. This means that tests will no longer need to wait for daemons. However, tests will still need a pidfile or such so they can stop the daemons. Note that the --detach options should not be used on OS X from launchd, only from tests.
This commit is contained in:
@@ -44,9 +44,8 @@
|
||||
|
||||
sig_atomic_t exit_flag = 0;
|
||||
|
||||
#ifdef SUPPORT_DETACH
|
||||
int detach_from_console = -1;
|
||||
#endif
|
||||
int daemon_child = -1;
|
||||
|
||||
static RETSIGTYPE
|
||||
sigterm(int sig)
|
||||
@@ -105,7 +104,6 @@ switch_environment(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@@ -157,10 +155,6 @@ main(int argc, char **argv)
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SUPPORT_DETACH
|
||||
if (detach_from_console)
|
||||
daemon(0, 0);
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
bonjour_announce(context, config);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user