summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/server/Daemon.cpp34
-rw-r--r--lib/server/Daemon.h1
2 files changed, 31 insertions, 4 deletions
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp
index 5ee45378..c639309a 100644
--- a/lib/server/Daemon.cpp
+++ b/lib/server/Daemon.cpp
@@ -51,7 +51,8 @@ Daemon *Daemon::spDaemon = 0;
Daemon::Daemon()
: mpConfiguration(NULL),
mReloadConfigWanted(false),
- mTerminateWanted(false)
+ mTerminateWanted(false),
+ mKeepConsoleOpenAfterFork(false)
{
if(spDaemon != NULL)
{
@@ -109,8 +110,9 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
#endif
char c;
+ optind = 0; // just in case anybody used getopt before
- while((c = getopt(argc, (char * const *)argv, "c:Dqv")) != -1)
+ while((c = getopt(argc, (char * const *)argv, "c:DqvVt:Tk")) != -1)
{
switch(c)
{
@@ -153,10 +155,34 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[])
}
break;
+ case 'V':
+ {
+ masterLevel = Log::EVERYTHING;
+ }
+ break;
+
+ case 't':
+ {
+ Console::SetTag(optarg);
+ }
+ break;
+
+ case 'T':
+ {
+ Console::SetShowTime(true);
+ }
+ break;
+
+ case 'k':
+ {
+ mKeepConsoleOpenAfterFork = true;
+ }
+ break;
+
case '?':
{
BOX_FATAL("Unknown option on command line: "
- << "'" << optopt << "'");
+ << "'" << (char)optopt << "'");
return 2;
}
break;
@@ -377,7 +403,7 @@ int Daemon::Main(const std::string &rConfigFileName, bool singleProcess)
}
#endif // BOX_MEMORY_LEAK_TESTING
- if(asDaemon)
+ if(asDaemon && !mKeepConsoleOpenAfterFork)
{
#ifndef WIN32
// Close standard streams
diff --git a/lib/server/Daemon.h b/lib/server/Daemon.h
index b28d752a..52bab257 100644
--- a/lib/server/Daemon.h
+++ b/lib/server/Daemon.h
@@ -77,6 +77,7 @@ private:
box_time_t mLoadedConfigModifiedTime;
bool mReloadConfigWanted;
bool mTerminateWanted;
+ bool mKeepConsoleOpenAfterFork;
static Daemon *spDaemon;
};