diff options
author | Adam <Adam@anope.org> | 2011-10-09 02:52:13 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-10-09 02:52:13 -0400 |
commit | 9f850334a1110a8b976e401af45264dcfc7315c4 (patch) | |
tree | 89dfda632fcc1f0a01d66ea67ea44b8dbfb8144f /src/init.cpp | |
parent | af273e3da537ff60edb5f97b8081b550bd56d57d (diff) |
Give more verbose messages on startup
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/init.cpp b/src/init.cpp index c4cd62b07..39dbb1c81 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -231,10 +231,35 @@ class SignalNothing : public Signal void OnNotify() { } }; -void Init(int ac, char **av) +bool AtTerm() +{ + return isatty(fileno(stdout)) && isatty(fileno(stdin)) && isatty(fileno(stderr)); +} + +void Fork() { - int started_from_term = isatty(0) && isatty(1) && isatty(2); +#ifndef _WIN32 + int i = fork(); + if (i < 0) + Log(LOG_TERMINAL) << "Unable to fork, " << Anope::LastError(); + else if (i != 0) + exit(0); + + if (isatty(fileno(stdout))) + fclose(stdout); + if (isatty(fileno(stdin))) + fclose(stdin); + if (isatty(fileno(stderr))) + fclose(stderr); + + setpgid(0, 0); +#else + FreeConsole(); +#endif +} +void Init(int ac, char **av) +{ /* Set file creation mask and group ID. */ #if defined(DEFUMASK) && HAVE_UMASK umask(DEFUMASK); @@ -361,36 +386,9 @@ void Init(int ac, char **av) /* Create me */ Me = new Server(NULL, Config->ServerName, 0, Config->ServerDesc, Config->Numeric); -#ifndef _WIN32 - if (!nofork) - { - int i; - if ((i = fork()) < 0) - throw FatalException("Unable to fork"); - else if (i != 0) - { - Log(LOG_TERMINAL) << "PID " << i; - exit(0); - } - - if (started_from_term) - { - close(0); - close(1); - close(2); - } - if (setpgid(0, 0) < 0) - throw FatalException("Unable to setpgid()"); - } -#else +#ifdef _WIN32 if (!SupportedWindowsVersion()) throw FatalException(GetWindowsVersion() + " is not a supported version of Windows"); - if (!nofork) - { - Log(LOG_TERMINAL) << "PID " << GetCurrentProcessId(); - Log() << "Launching Anope into the background"; - FreeConsole(); - } #endif /* Write our PID to the PID file. */ @@ -417,7 +415,8 @@ void Init(int ac, char **av) #endif /* load modules */ - ModuleManager::LoadModuleList(Config->ModulesAutoLoad); + for (std::list<Anope::string>::iterator it = Config->ModulesAutoLoad.begin(), it_end = Config->ModulesAutoLoad.end(); it != it_end; ++it) + ModuleManager::LoadModule(*it, NULL); Module *protocol = ModuleManager::FindFirstOf(PROTOCOL); if (protocol == NULL) |