[launchd-changes] [23802] trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 12 10:52:13 PST 2009


Revision: 23802
          http://trac.macosforge.org/projects/launchd/changeset/23802
Author:   dsorresso at apple.com
Date:     2009-02-12 10:52:12 -0800 (Thu, 12 Feb 2009)
Log Message:
-----------
<rdar://problem/6501491> rebooting at the end of the restore takes longer than it used to
Changed auto-label generation to distinguish between anonymous jobs and legacy mach_init jobs.

Modified Paths:
--------------
    trunk/launchd/src/launchctl.c
    trunk/launchd/src/launchd_core_logic.c
    trunk/launchd.xcodeproj/project.pbxproj

Modified: trunk/launchd/src/launchctl.c
===================================================================
--- trunk/launchd/src/launchctl.c	2009-02-12 02:56:06 UTC (rev 23801)
+++ trunk/launchd/src/launchctl.c	2009-02-12 18:52:12 UTC (rev 23802)
@@ -1791,6 +1791,8 @@
 #if TARGET_OS_EMBEDDED
 	if (path_check("/etc/rc.boot")) {
 		const char *rcboot_tool[] = { "/etc/rc.boot", NULL };
+		
+		assumes(signal(SIGTERM, exit_at_sigterm) != SIG_ERR);
 		assumes(fwexec(rcboot_tool, NULL) != -1);
 	}
 #endif

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2009-02-12 02:56:06 UTC (rev 23801)
+++ trunk/launchd/src/launchd_core_logic.c	2009-02-12 18:52:12 UTC (rev 23802)
@@ -392,6 +392,7 @@
 static void jobmgr_log_bug(jobmgr_t jm, unsigned int line);
 
 #define AUTO_PICK_LEGACY_LABEL (const char *)(~0)
+#define AUTO_PICK_ANONYMOUS_LABEL (const char *)(~1)
 
 struct job_s {
 	kq_callback kqjob_callback;	/* MUST be first element of this structure for benefit of launchd's run loop. */
@@ -1373,7 +1374,7 @@
 		jm->shutting_down = false;
 	}
 
-	if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_LEGACY_LABEL, kp.kp_proc.p_comm, NULL)) != NULL)) {
+	if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_ANONYMOUS_LABEL, kp.kp_proc.p_comm, NULL)) != NULL)) {
 		u_int proc_fflags = NOTE_EXEC|NOTE_FORK|NOTE_EXIT|NOTE_REAP;
 
 		total_anon_children++;
@@ -1431,14 +1432,15 @@
 		return NULL;
 	}
 
-	if (unlikely(label == AUTO_PICK_LEGACY_LABEL)) {
+	char *anon_or_legacy = ( label == AUTO_PICK_ANONYMOUS_LABEL ) ? "anonymous" : "mach_init";
+	if (unlikely(label == AUTO_PICK_LEGACY_LABEL || label == AUTO_PICK_ANONYMOUS_LABEL)) {
 		if (prog) {
 			bn = prog;
 		} else {
 			strlcpy(tmp_path, argv[0], sizeof(tmp_path));
 			bn = basename(tmp_path); /* prog for auto labels is kp.kp_kproc.p_comm */
 		}
-		snprintf(auto_label, sizeof(auto_label), "%s.%s", sizeof(void *) == 8 ? "0xdeadbeeffeedface" : "0xbabecafe", bn);
+		snprintf(auto_label, sizeof(auto_label), "%s.%s.%s", sizeof(void *) == 8 ? "0xdeadbeeffeedface" : "0xbabecafe", anon_or_legacy, bn);
 		label = auto_label;
 		/* This is so we can do gross things later. See NOTE_EXEC for anonymous jobs */
 		minlabel_len = strlen(label) + MAXCOMLEN;
@@ -1453,7 +1455,7 @@
 	}
 
 	if (unlikely(label == auto_label)) {
-		snprintf((char *)j->label, strlen(label) + 1, "%p.%s", j, bn);
+		snprintf((char *)j->label, strlen(label) + 1, "%p.%s.%s", j, anon_or_legacy, bn);
 	} else {
 		strcpy((char *)j->label, label);
 	}
@@ -3153,7 +3155,7 @@
 			if (job_assumes(j, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) && len == sizeof(kp)) {
 				char newlabel[1000];
 
-				snprintf(newlabel, sizeof(newlabel), "%p.%s", j, kp.kp_proc.p_comm);
+				snprintf(newlabel, sizeof(newlabel), "%p.anonymous.%s", j, kp.kp_proc.p_comm);
 
 				job_log(j, LOG_INFO, "Program changed. Updating the label to: %s", newlabel);
 				j->lastlookup = NULL;

Modified: trunk/launchd.xcodeproj/project.pbxproj
===================================================================
--- trunk/launchd.xcodeproj/project.pbxproj	2009-02-12 02:56:06 UTC (rev 23801)
+++ trunk/launchd.xcodeproj/project.pbxproj	2009-02-12 18:52:12 UTC (rev 23802)
@@ -136,14 +136,14 @@
 			isa = PBXContainerItemProxy;
 			containerPortal = FC59A03F0E8C87FD00D41150 /* Project object */;
 			proxyType = 1;
-			remoteGlobalIDString = 4B10F1B70F43BE7E00875782 /* launchd-embedded */;
+			remoteGlobalIDString = 4B10F1B70F43BE7E00875782;
 			remoteInfo = "launchd-embedded";
 		};
 		4B10F1F50F43BF8C00875782 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = FC59A03F0E8C87FD00D41150 /* Project object */;
 			proxyType = 1;
-			remoteGlobalIDString = 4B10F1E60F43BF5C00875782 /* launchctl-embedded */;
+			remoteGlobalIDString = 4B10F1E60F43BF5C00875782;
 			remoteInfo = "launchctl-embedded";
 		};
 		726056260EA808B700D65FE7 /* PBXContainerItemProxy */ = {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090212/379b977c/attachment.html>


More information about the launchd-changes mailing list