From 3f4fbb8e65c497fad195a04bb1482ceffdf06d5d Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sun, 6 Jan 2008 08:19:25 +0000 Subject: [PATCH] Mac Client: more idle time tweaks to allow running as a daemon by using Mac OS X's launchd mechanism. svn path=/trunk/boinc/; revision=14471 --- checkin_notes | 10 ++++++++++ client/hostinfo_unix.C | 13 +++++++++++-- client/main.C | 7 +------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/checkin_notes b/checkin_notes index 6bc58ea40c..d1716116e3 100644 --- a/checkin_notes +++ b/checkin_notes @@ -107,3 +107,13 @@ David Jan 4 2008 sample_index.php tools/ make_project + + +Charlie Jan 6 2008 + - Mac Client: more idle time tweaks to allow running as a daemon by + using Mac OS X's launchd mechanism. + - Mac: Update script which sets BOINC up to run as a daemon so it + + client/ + hostinfo_unix.C + main.C diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index 35fcf943a8..fe0733bf01 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -92,7 +92,7 @@ extern "C" { } // extern "C" #endif -NXEventHandle gEventHandle; +NXEventHandle gEventHandle = NULL; #endif // __APPLE__ #ifdef _HPUX_SOURCE @@ -861,7 +861,16 @@ inline bool all_logins_idle(time_t t) { bool HOST_INFO::users_idle( bool check_all_logins, double idle_time_to_run, double *actual_idle_time ) { - double idleTime = NXIdleTime(gEventHandle); + double idleTime = 0; + + if (gEventHandle) { + idleTime = NXIdleTime(gEventHandle); + } else { + // Initialize Mac OS X idle time measurement / idle detection + // Do this here because NXOpenEventStatus() may not be available + // immediately on system startup when running as a deaemon. + gEventHandle = NXOpenEventStatus(); + } if (actual_idle_time) { *actual_idle_time = idleTime; diff --git a/client/main.C b/client/main.C index ca99e567b8..3508fc20f5 100644 --- a/client/main.C +++ b/client/main.C @@ -665,11 +665,6 @@ int main(int argc, char** argv) { break; } } -#elif defined(__APPLE__) - // If the real user ID is root, we are executing as a daemon - if (getuid() == (uid_t)0) { - gstate.executing_as_daemon = true; - } #elif defined __EMX__ #else // non-Apple Unix @@ -753,7 +748,7 @@ int main(int argc, char** argv) { SetBOINCDataOwnersGroupsAndPermissions(); } #endif // _DEBUG && __APPLE__ - int i = check_security(g_use_sandbox, false); + i = check_security(g_use_sandbox, false); if (i) { printf( "File ownership or permissions are set in a way that\n"