[launchd-changes] [23944] branches/PR-7084138/launchd/src/launchd_core_logic.c

source_changes at macosforge.org source_changes at macosforge.org
Thu Oct 22 16:22:05 PDT 2009


Revision: 23944
          http://trac.macosforge.org/projects/launchd/changeset/23944
Author:   dsorresso at apple.com
Date:     2009-10-22 16:22:04 -0700 (Thu, 22 Oct 2009)
Log Message:
-----------
Fix for rdar://problem/7084138.

Modified Paths:
--------------
    branches/PR-7084138/launchd/src/launchd_core_logic.c

Modified: branches/PR-7084138/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-7084138/launchd/src/launchd_core_logic.c	2009-10-22 23:17:18 UTC (rev 23943)
+++ branches/PR-7084138/launchd/src/launchd_core_logic.c	2009-10-22 23:22:04 UTC (rev 23944)
@@ -8608,7 +8608,7 @@
 		job_handle_mpm_wait(NULL, MACH_PORT_NULL, NULL);
 	}
 	struct ldcred *ldc = runtime_get_caller_creds();
-	job_t calling_j = job_mig_intran2(j->mgr, MACH_PORT_NULL, ldc->pid);
+	job_t calling_j = jobmgr_find_by_pid(j->mgr, ldc->pid, true);
 	
 	return job_mig_wait2(calling_j, j, srp, waitstatus, true);
 #endif
@@ -8627,7 +8627,17 @@
 		return BOOTSTRAP_NO_MEMORY;
 	}
 	
-	if( target_j->p == 0 ) {
+	/* See rdar://problem/7084138 for why we do the second part of this check.
+	 * Basically, since Finder, Dock and SystemUIServer are now real launchd
+	 * jobs, they don't get removed after exiting, like legacy LaunchServices
+	 * jobs do. So there's a race. coreservicesd came in asking for the exit
+	 * status after we'd relaunched Finder, so Finder's PID isn't 0.
+	 *
+	 * So we check to make sure the target job isn't a LaunchServices job and
+	 * that the request is coming through the legacy path (mpm_wait()). If so,
+	 * we return the last exit status, regardless of the current PID value.
+	 */
+	if( target_j->p == 0 || (!target_j->legacy_LS_job && legacy) ) {
 		*status = target_j->last_exit_status;
 		return BOOTSTRAP_SUCCESS;
 	}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20091022/f757665f/attachment.html>


More information about the launchd-changes mailing list