[dss-commits] r8846 - dss/trunk
dss-commits at forum.digitalstrom.org
dss-commits at forum.digitalstrom.org
Thu Oct 15 12:09:12 CEST 2009
Author: pstaehlin
Date: 2009-10-15 12:09:12 +0200 (Thu, 15 Oct 2009)
New Revision: 8846
Modified:
dss/trunk/main.cpp
Log:
Daemonize dSS on request.
Pass -d or --daemonize on the command line.
Closes #133
Modified: dss/trunk/main.cpp
===================================================================
--- dss/trunk/main.cpp 2009-10-15 10:08:30 UTC (rev 8845)
+++ dss/trunk/main.cpp 2009-10-15 10:09:12 UTC (rev 8846)
@@ -107,6 +107,9 @@
#endif
("prop", po::value<vector<string> >(), "sets a property")
("version,v", "print version information and exit")
+#ifndef __APPLE__ // daemon() is marked as deprecated on OS X
+ ("daemonize,d", "start as a daemon")
+#endif
;
po::variables_map vm;
@@ -146,6 +149,10 @@
snifferDev = vm["sniff"].as<string>();
}
+#ifndef __APPLE__
+ bool daemonize = vm.count("daemonize") != 0;
+#endif
+
#ifdef WITH_TESTS
cout << "compiled WITH_TESTS" << endl;
if(runTests) {
@@ -167,6 +174,15 @@
if(!quitAfterTests) {
// start DSS
dss::DSS::getInstance()->initialize(properties);
+#ifndef __APPLE__
+ if(daemonize) {
+ int result = daemon(1,0);
+ if(result != 0) {
+ perror("daemon()");
+ return 0;
+ }
+ }
+#endif
dss::DSS::getInstance()->run();
}
if(dss::DSS::hasInstance()) {
More information about the dss-commits
mailing list