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);
    }
       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));
 
       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);
 
       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 */
 
 
    if (argc)
       usage();
 
+   if (!foreground) {
+      daemon_start();                 /* become daemon */
+      init_stack_dump();              /* pick up new pid */
+   }
+
    if (!no_signals) {
       init_signals(terminate_stored);
    }
 
    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));