[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src/server server.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src/server server.cpp |
Date: |
Wed, 02 Mar 2005 23:19:16 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/03/03 04:19:16
Modified files:
src/server : server.cpp
Log message:
added support for running wesnothd as a daemon
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/server.cpp.diff?tr1=1.66&tr2=1.67&r1=text&r2=text
Patches:
Index: wesnoth/src/server/server.cpp
diff -u wesnoth/src/server/server.cpp:1.66 wesnoth/src/server/server.cpp:1.67
--- wesnoth/src/server/server.cpp:1.66 Sun Feb 20 22:30:29 2005
+++ wesnoth/src/server/server.cpp Thu Mar 3 04:19:16 2005
@@ -23,6 +23,11 @@
#include <vector>
#include <signal.h>
+
+#ifndef WIN32
+#include <sys/types.h>
+#include <unistd.h>
+#endif
namespace {
@@ -902,6 +907,20 @@
}
fifo_path = argv[arg];
+ } else if(val == "--daemon" || val == "-d") {
+#ifdef WIN32
+ std::cerr << "Running as a daemon is not supported on
this platform\n";
+ return -1;
+#else
+ const pid_t pid = fork();
+ if(pid < 0) {
+ std::cerr << "Could not fork and run as a
daemon\n";
+ return -1;
+ } else {
+ std::cout << "Started wesnothd as a daemon with
process id " << pid << "\n";
+ return 0;
+ }
+#endif
} else if(val[0] == '-') {
std::cerr << "unknown option: " << val << "\n";
return 0;