X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=main.cpp;h=064537cd79a0572ef706e66c52106ce522f8026d;hb=9819131192eec224aa3aef48ef228604b6b098e5;hp=75c36d8d6a409c025d67e65ba092b67a0ba85d91;hpb=867275636c6b2526f6626e503e8e72a21776370f;p=cubemap diff --git a/main.cpp b/main.cpp index 75c36d8..064537c 100644 --- a/main.cpp +++ b/main.cpp @@ -291,6 +291,16 @@ int main(int argc, char **argv) if (test_config) { exit(0); } + + // Ideally we'd like to daemonize only when we've started up all threads etc., + // but daemon() forks, which is not good in multithreaded software, so we'll + // have to do it here. + if (config.daemonize) { + if (daemon(0, 0) == -1) { + log_perror("daemon"); + exit(1); + } + } start: // Open logs as soon as possible. @@ -417,7 +427,7 @@ start: } // OK, so the signal was SIGHUP. Check that the new config is okay, then exec the new binary. - if (!dry_run_config(argv[0], config_filename)) { + if (!dry_run_config(argv0_canon, config_filename_canon)) { open_logs(config.log_destinations); log(ERROR, "%s --test-config failed. Restarting old version instead of new.", argv[0]); hupped = false;