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");
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);
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 */
construct_umodebuf();
check_class();
+ write_pidfile(pidFileName);
load_help();
open_logfiles();
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);