X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=main.cpp;h=2c5ef67d90bb78b7c897040ce8d3710d6975c044;hp=75c36d8d6a409c025d67e65ba092b67a0ba85d91;hb=a313e4c7a3c0c453d4dffd317fc143f1f4a7f8ba;hpb=867275636c6b2526f6626e503e8e72a21776370f diff --git a/main.cpp b/main.cpp index 75c36d8..2c5ef67 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.