Revision: 23951 http://trac.macosforge.org/projects/launchd/changeset/23951 Author: dsorresso@apple.com Date: 2009-11-17 16:45:29 -0800 (Tue, 17 Nov 2009) Log Message: ----------- Yet again. Modified Paths: -------------- branches/PR-7264615/launchd/src/launchd_core_logic.c Modified: branches/PR-7264615/launchd/src/launchd_core_logic.c =================================================================== --- branches/PR-7264615/launchd/src/launchd_core_logic.c 2009-11-18 00:24:45 UTC (rev 23950) +++ branches/PR-7264615/launchd/src/launchd_core_logic.c 2009-11-18 00:45:29 UTC (rev 23951) @@ -1427,28 +1427,11 @@ return NULL; } - switch (kp.kp_eproc.e_ppid) { - case 0: - /* the kernel */ - break; - case 1: - if (!pid1_magic) { - /* we cannot possibly find a parent job_t that is useful in this function */ - break; - } - /* fall through */ - default: - jp = jobmgr_find_by_pid(jm, kp.kp_eproc.e_ppid, true); - jobmgr_assumes(jm, jp != NULL); - break; - } - if (jp && !jp->anonymous && unlikely(!(kp.kp_proc.p_flag & P_EXEC))) { job_log(jp, LOG_DEBUG, "Called *fork(). Please switch to posix_spawn*(), pthreads or launchd. Child PID %u", kp.kp_proc.p_pid); } - /* A total hack: Normally, job_new() returns an error during shutdown, but anonymous jobs are special. */ if (unlikely(shutdown_state = jm->shutting_down)) { jm->shutting_down = false; @@ -1481,6 +1464,25 @@ jm->shutting_down = true; } + /* This is down here to mitigate the effects of rdar://problem/7264615, in which a process + * attaches to its own parent. + */ + switch (kp.kp_eproc.e_ppid) { + case 0: + /* the kernel */ + break; + case 1: + if (!pid1_magic) { + /* we cannot possibly find a parent job_t that is useful in this function */ + break; + } + /* fall through */ + default: + jp = jobmgr_find_by_pid(jm, kp.kp_eproc.e_ppid, true); + jobmgr_assumes(jm, jp != NULL); + break; + } + return jr; }