Become a daemon, discarding the controlling terminal.
****************************************************************************/
-_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group)
+_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout)
{
if (do_fork) {
if (sys_fork()) {
}
#endif /* HAVE_SETSID */
- /* Close fd's 0,1,2. Needed if started by rsh */
- close_low_fds(false); /* Don't close stderr, let the debug system
- attach it to the logfile */
+ if (!log_stdout) {
+ /* Close fd's 0,1,2. Needed if started by rsh */
+ close_low_fds(false); /* Don't close stderr, let the debug system
+ attach it to the logfile */
+ }
}
/**
Become a daemon, discarding the controlling terminal.
**/
-_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group);
+_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout);
/**
* Load a ini-style file.
if (is_daemon && !opt_interactive) {
DEBUG( 2, ( "Becoming a daemon.\n" ) );
- become_daemon(Fork, no_process_group);
+ become_daemon(Fork, no_process_group, log_stdout);
}
#if HAVE_SETPGID
if (is_daemon && !interactive) {
DEBUG( 3, ( "Becoming a daemon.\n" ) );
- become_daemon(Fork, no_process_group);
+ become_daemon(Fork, no_process_group, log_stdout);
}
#if HAVE_SETPGID
}
if (asprintf(&binfile, "%s/smbd", get_dyn_SBINDIR()) > 0) {
- become_daemon(true, false);
+ become_daemon(true, false, false);
execl(binfile, binfile, "-D", NULL);
}
exit(0);
}
if (asprintf(&binfile, "%s/nmbd", get_dyn_SBINDIR()) > 0) {
- become_daemon(true, false);
+ become_daemon(true, false, false);
execl(binfile, binfile, "-D", NULL);
}
exit(0);
}
if (asprintf(&binfile, "%s/winbindd", get_dyn_SBINDIR()) > 0) {
- become_daemon(true, false);
+ become_daemon(true, false, false);
execl(binfile, binfile, NULL);
}
exit(0);
BlockSignals(False, SIGCHLD);
if (!interactive)
- become_daemon(Fork, no_process_group);
+ become_daemon(Fork, no_process_group, log_stdout);
pidfile_create("winbindd");
if (opt_daemon) {
DEBUG(3,("Becoming a daemon.\n"));
- become_daemon(true, false);
+ become_daemon(true, false, false);
}
cleanup_tmp_files(cmdline_lp_ctx);