[launchd-changes] [23948] branches/PR-7264615/launchd/src/launchd_core_logic.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Nov 17 16:01:47 PST 2009
Revision: 23948
http://trac.macosforge.org/projects/launchd/changeset/23948
Author: dsorresso at apple.com
Date: 2009-11-17 16:01:44 -0800 (Tue, 17 Nov 2009)
Log Message:
-----------
"Fix" for rdar://problem/7264615.
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-17 23:25:41 UTC (rev 23947)
+++ branches/PR-7264615/launchd/src/launchd_core_logic.c 2009-11-18 00:01:44 UTC (rev 23948)
@@ -1417,7 +1417,17 @@
kp_euid, kp_uid, kp_svuid, kp_egid, kp_gid, kp_svgid, anonpid, kp.kp_proc.p_comm);
}
- switch (kp.kp_eproc.e_ppid) {
+ /* "Fix" for a problem that shouldn't even exist.
+ * See rdar://problem/7264615 for the symptom and rdar://problem/5020256
+ * as to why this can happen.
+ */
+ pid_t ppid = kp.kp_eproc.e_ppid;
+ if( !jobmgr_assumes(jm, ppid != anonpid) ) {
+ jobmgr_log(jm, LOG_WARNING, "Process has become its own parent through ptrace(3). It should find a different way to do whatever it's doing. Setting PPID to 0: %s", kp.kp_proc.p_comm);
+ ppid = 0;
+ }
+
+ switch (ppid) {
case 0:
/* the kernel */
break;
@@ -3249,7 +3259,15 @@
*
* Otherwise, we wait for the death of the parent tracer and then reap, just as we
* would if a job died while we were sampling it at shutdown.
+ *
+ * Note that we foolishly assume that in the process *tree* a node cannot be its
+ * own parent. Apparently, that is not correct. If this is the case, we forsake
+ * the process to its own device. Let it reap itself.
*/
+ if( !job_assumes(j, kp.kp_eproc.e_ppid != (pid_t)kev->ident) ) {
+ job_log(j, LOG_WARNING, "Job is its own parent and has (somehow) exited. Leaving it to waste away.");
+ return;
+ }
if( job_assumes(j, kevent_mod(kp.kp_eproc.e_ppid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, j) != -1) ) {
j->tracing_pid = kp.kp_eproc.e_ppid;
j->reap_after_trace = true;
@@ -7325,6 +7343,12 @@
return 1;
}
+ if( !job_assumes(j, pid_to_log == kp.kp_eproc.e_ppid) ) {
+ job_log(j, LOG_WARNING, "Job which is its own parent started reboot.");
+ snprintf(who_started_the_reboot, sizeof(who_started_the_reboot), "%s[%u]->%s[%u]->%s[%u]->...", kp.kp_proc.p_comm, pid_to_log, kp.kp_proc.p_comm, pid_to_log, kp.kp_proc.p_comm, pid_to_log);
+ break;
+ }
+
who_offset = strlen(who_started_the_reboot);
snprintf(who_started_the_reboot + who_offset, sizeof(who_started_the_reboot) - who_offset,
" %s[%u]%s", kp.kp_proc.p_comm, pid_to_log, kp.kp_eproc.e_ppid ? " ->" : "");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20091117/9f597eda/attachment.html>
More information about the launchd-changes
mailing list