From 6e89135a0ac092afb65988fecaebcefb1dcb62f1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 16 Jan 2006 04:09:03 +0000 Subject: [PATCH] -daemon option svn path=/trunk/boinc/; revision=9239 --- checkin_notes | 9 +++++++++ client/cs_cmdline.C | 1 + client/main.C | 15 ++++++++++++++- doc/client_unix.php | 3 +++ doc/contact.php | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/checkin_notes b/checkin_notes index 7a43e0851b..a5cd5456ee 100755 --- a/checkin_notes +++ b/checkin_notes @@ -440,3 +440,12 @@ Rom 15 Jan 2006 Rom 15 Jan 2006 (HEAD) - Tag for 5.3.11 release, all platforms boinc_core_release_5_3_11 + +David 15 Jan 2006 + - core client: add "-daemon" option (uses daemon() system call + to detach from controlling terminal) + From Jan Gall + + client/ + cs_cmdline.C + main.C diff --git a/client/cs_cmdline.C b/client/cs_cmdline.C index c2062b6f91..4d9609da12 100644 --- a/client/cs_cmdline.C +++ b/client/cs_cmdline.C @@ -52,6 +52,7 @@ static void print_options(char* prog) { " -detach detach from console (Windows)\n" " -dir use given dir as BOINC home\n" " -no_gui_rpc don't allow GUI RPC, don't make socket\n" + " -daemon run as daemon (Unix)\n" , prog ); diff --git a/client/main.C b/client/main.C index 949bf8c9fc..5c75494866 100644 --- a/client/main.C +++ b/client/main.C @@ -45,9 +45,9 @@ typedef void (CALLBACK* IdleTrackerTerm)(); #include #include #endif +#include #include #include -//#include "synch.h" #endif #ifdef __APPLE__ @@ -498,6 +498,19 @@ int main(int argc, char** argv) { break; } } +#elif defined linux + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-daemon") == 0 || strcmp(argv[i], "--daemon") == 0) { + syslog(LOG_DAEMON, "Starting Boinc-Daemon, listening on port %d.", GUI_RPC_PORT); + // from : + // Detach from the controlling terminal and run in the background as system daemon. + // Don't change working directory to root ("/"), but redirect + // standard input, standard output and standard error to /dev/null. + daemon(1, 0); + break; + } + } #endif boinc_cleanup_completed = false; diff --git a/doc/client_unix.php b/doc/client_unix.php index 7b8e929f27..b30561e04e 100644 --- a/doc/client_unix.php +++ b/doc/client_unix.php @@ -71,6 +71,9 @@ list_item("-detach", list_item("-no_gui_rpc", "Don't allow GUI RPCs." ); +list_item("-daemon", + "Run as daemon (detach from controlling terminal; Linux only) +); list_end(); echo "

Environment variables

diff --git a/doc/contact.php b/doc/contact.php index ac002178b1..51dbef9458 100644 --- a/doc/contact.php +++ b/doc/contact.php @@ -119,6 +119,7 @@ show_name("Glenn Dill"); show_name("James Drews"); show_name("Charlie Fenton"); show_name("John Flynn III"); +show_name("Jan Gall"); show_name("Michael Gary"); show_name("Marco Gazzoni"); show_name("Gary Gibson");