Signal documentation
[distributedratelimiting.git] / ulogd.c
diff --git a/ulogd.c b/ulogd.c
index 9b998a9..4553d4d 100644 (file)
--- a/ulogd.c
+++ b/ulogd.c
@@ -769,6 +769,17 @@ int main(int argc, char* argv[])
                }
        }
 
+       if (daemonize){
+               if (fork()) {
+                       exit(0);
+               }
+               if (logfile != stdout)
+                       fclose(stdout);
+               fclose(stderr);
+               fclose(stdin);
+               setsid();
+       }
+
        logfile_open(logf_ce.u.string);
 
        for (p = ulogd_outputs; p; p = p->next) {
@@ -781,16 +792,6 @@ int main(int argc, char* argv[])
        interh_dump();
        keyh_dump();
 #endif
-       if (daemonize){
-               if (fork()) {
-                       exit(0);
-               }
-               if (logfile != stdout)
-                       fclose(stdout);
-               fclose(stderr);
-               fclose(stdin);
-               setsid();
-       }
 
        /* send SIGINT to the term handler, since they hit CTRL-C */
        signal(SIGINT, &sigterm_handler);