- if (common_setup(pidfile, true, NULL, NULL, daemonize) != EXIT_SUCCESS
- || start_listener(config->port) < 0) {
+ if (daemonize && daemon_detach() < 0) {
+ crit("unable to fork");
+ return EXIT_FAILURE;
+ }
+
+ pidfile_refresh();
+
+ if (start_listener(config->port) < 0) {