diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-03 00:33:52 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-03 00:33:52 +0000 |
commit | 37ca99f87272214d1b647f734f9ef4334b605779 (patch) | |
tree | d0fffe2c1fa09ad96af80396a546b72acd30797d /src/inspircd.cpp | |
parent | 6fffe28853f4b64db3c266d45f140a5284d3dc2a (diff) |
Added -nofork parameter which allows you to force inspircd into the foreground for gdb debugging
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@360 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r-- | src/inspircd.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 062a07995..444287834 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -81,6 +81,8 @@ vector<int> fd_reap; extern int MODCOUNT; +bool nofork = false; + namespace nspace { template<> struct nspace::hash<in_addr> @@ -279,6 +281,11 @@ void log(int level,char *text, ...) b[strlen(b)-1] = ':'; fprintf(f,"%s %s\n",b,textbuffer); fclose(f); + if (nofork) + { + // nofork enabled? display it on terminal too + printf("%s %s\n",b,textbuffer); + } } else { @@ -2873,6 +2880,11 @@ int main (int argc, char *argv[]) printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n"); Exit(ERROR); } + if (argc > 1) { + if (!strcmp(argv[1],"-nofork")) { + nofork = true; + } + } if (InspIRCd() == ERROR) { log(DEBUG,"main: daemon function bailed"); @@ -4601,11 +4613,18 @@ int InspIRCd(void) startup_time = time(NULL); - if (DaemonSeed() == ERROR) + if (nofork) { - log(DEBUG,"InspIRCd: startup: can't daemonise"); - printf("ERROR: could not go into daemon mode. Shutting down.\n"); - Exit(ERROR); + log(VERBOSE,"Not forking as -nofork was specified"); + } + else + { + if (DaemonSeed() == ERROR) + { + log(DEBUG,"InspIRCd: startup: can't daemonise"); + printf("ERROR: could not go into daemon mode. Shutting down.\n"); + Exit(ERROR); + } } |