]> jfr.im git - solanum.git/blobdiff - ircd/ircd.c
m_cap: use rn_snprintf_try_append
[solanum.git] / ircd / ircd.c
index de8e80a4fe95084d441e61008a4ea2f315ba1322..d68430720be145440e2d1430a89fb99d4cc29b6d 100644 (file)
@@ -225,6 +225,12 @@ make_daemon(void)
           we need control over the parent after forking to print
           the startup message -- Aaron */
 
+       if((nullfd = open("/dev/null", O_RDWR)) < 0)
+       {
+               perror("open /dev/null");
+               exit(EXIT_FAILURE);
+       }
+
        if((pid = fork()) < 0)
        {
                perror("fork");
@@ -238,12 +244,6 @@ make_daemon(void)
                exit(EXIT_SUCCESS);
        }
 
-       if((nullfd = open("/dev/null", O_RDWR)) < 0)
-       {
-               perror("open /dev/null");
-               exit(EXIT_FAILURE);
-       }
-
        for(fdx = 0; fdx <= 2; fdx++)
                if (fdx != nullfd)
                        (void) dup2(nullfd, fdx);
@@ -724,8 +724,14 @@ charybdis_main(int argc, char * const argv[])
        if(!testing_conf)
        {
                check_pidfile(pidFileName);
+
                inotice("starting %s ...", ircd_version);
                inotice("%s", rb_lib_version());
+
+#ifndef _WIN32
+               if(!server_state_foreground)
+                       make_daemon();
+#endif
        }
 
        /* Init the event subsystem */
@@ -838,6 +844,7 @@ charybdis_main(int argc, char * const argv[])
        construct_umodebuf();
 
        check_class();
+       write_pidfile(pidFileName);
        load_help();
        open_logfiles();
 
@@ -861,12 +868,6 @@ charybdis_main(int argc, char * const argv[])
        if(server_state_foreground)
                inotice("now running in foreground mode from %s as pid %d ...",
                        ConfigFileEntry.dpath, getpid());
-#ifndef _WIN32
-       else
-               make_daemon();
-#endif
-
-       write_pidfile(pidFileName);
 
        rb_lib_loop(0);