From 416561d701fd662bd5c8f12b32e73832d915279d Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 26 May 2015 13:13:34 +0200 Subject: [PATCH] Fix bug 2141 --- bacula/src/dird/dird.c | 13 ++++++++----- bacula/src/filed/filed.c | 10 +++++----- bacula/src/stored/stored.c | 9 +++++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 8706334579..2df4c6d601 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -256,6 +256,13 @@ int main (int argc, char *argv[]) usage(); } + if (!test_config) { /* we don't need to do this block in test mode */ + if (background) { + daemon_start(); + init_stack_dump(); /* grab new pid */ + } + } + if (configfile == NULL) { configfile = bstrdup(CONFIG_FILE); } @@ -271,11 +278,7 @@ int main (int argc, char *argv[]) Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile); } - if (!test_config) { /* we don't need to do this block in test mode */ - if (background) { - daemon_start(); - init_stack_dump(); /* grab new pid */ - } + if (!test_config) { /* Create pid must come after we are a daemon -- so we have our final pid */ create_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index 69d5aa95f4..d4e51f8027 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -197,6 +197,11 @@ int main (int argc, char *argv[]) configfile = bstrdup(CONFIG_FILE); } + if (!foreground) { + daemon_start(); + init_stack_dump(); /* set new pid */ + } + config = new_config_parser(); parse_fd_config(config, configfile, M_ERROR_TERM); @@ -216,11 +221,6 @@ int main (int argc, char *argv[]) terminate_filed(0); } - if (!foreground) { - daemon_start(); - init_stack_dump(); /* set new pid */ - } - set_thread_concurrency(me->MaxConcurrentJobs + 10); lmgr_init_thread(); /* initialize the lockmanager stack */ diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index ab548daa62..1429aa7a5f 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -202,6 +202,11 @@ int main (int argc, char *argv[]) if (argc) usage(); + if (!foreground) { + daemon_start(); /* become daemon */ + init_stack_dump(); /* pick up new pid */ + } + if (!no_signals) { init_signals(terminate_stored); } @@ -229,10 +234,6 @@ int main (int argc, char *argv[]) my_name_is(0, (char **)NULL, me->hdr.name); /* Set our real name */ - if (!foreground) { - daemon_start(); /* become daemon */ - init_stack_dump(); /* pick up new pid */ - } create_pid_file(me->pid_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs)); -- 2.39.5