[23663] branches/PR-5039559/launchd/src/launchd.c
Revision: 23663 http://trac.macosforge.org/projects/launchd/changeset/23663 Author: dsorresso@apple.com Date: 2008-08-14 19:20:45 -0700 (Thu, 14 Aug 2008) Log Message: ----------- Added update thread. No parameter grabbing yet though. Modified Paths: -------------- branches/PR-5039559/launchd/src/launchd.c Modified: branches/PR-5039559/launchd/src/launchd.c =================================================================== --- branches/PR-5039559/launchd/src/launchd.c 2008-08-14 21:16:49 UTC (rev 23662) +++ branches/PR-5039559/launchd/src/launchd.c 2008-08-15 02:20:45 UTC (rev 23663) @@ -96,6 +96,8 @@ static void fatal_signal_handler(int sig, siginfo_t *si, void *uap); static void handle_pid1_crashes_separately(void); +static void update_thread(unsigned int freq); + static bool re_exec_in_single_user_mode; static void *crash_addr; static pid_t crash_pid; @@ -165,6 +167,22 @@ _vproc_transaction_end(); } +//#if TARGET_OS_EMBEDDED + if( getpid() == 1 ) { + /* Start the update thread -- rdar://problem/5039559 */ + pthread_t t = NULL; + int freq = 30; + int err = pthread_create(&t, NULL, (void (*)(void *))update_thread, (void *)freq); + if( err != 0 ) { + /* If we hit this condition, there's something horribly wrong. + * We're the first process; we shouldn't be running out of threads or anything + * whacky like that. + */ + fprintf(stderr, "%s: Dude, your system is seriously messed up (%d - %s). I'm guessing you'll crash very soon.\n", getprogname(), err, strerror(err)); + } + } +//#endif + jobmgr_init(sflag); launchd_runtime_init2(); @@ -187,6 +205,14 @@ launchd_assumes(sigaction(SIGSEGV, &fsa, NULL) != -1); } +static void update_thread(unsigned int freq) +{ + while( true ) { + sync(); + sleep(freq); + } +} + #define PID1_CRASH_LOGFILE "/var/log/launchd-pid1.crash" /* This hack forces the dynamic linker to resolve these symbols ASAP */
participants (1)
-
source_changes@macosforge.org