[launchd-changes] [23495] trunk/launchd/src/launchd_core_logic.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Jan 23 14:25:38 PST 2008


Revision: 23495
          http://trac.macosforge.org/projects/launchd/changeset/23495
Author:   zarzycki at apple.com
Date:     2008-01-23 14:25:34 -0800 (Wed, 23 Jan 2008)

Log Message:
-----------
Speculative work.

Modified Paths:
--------------
    trunk/launchd/src/launchd_core_logic.c

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2008-01-23 18:11:46 UTC (rev 23494)
+++ trunk/launchd/src/launchd_core_logic.c	2008-01-23 22:25:34 UTC (rev 23495)
@@ -2410,7 +2410,13 @@
 void
 job_log_chidren_without_exec(job_t j)
 {
+	/* <rdar://problem/5701343> ER: Add a KERN_PROC_PPID sysctl */
+#ifdef KERN_PROC_PPID
+	int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PPID, j->p };
+#else
 	int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
+#endif
+	int mib_sz = sizeof(mib) / sizeof(mib[0]);
 	size_t i, kp_cnt, len = 10*1024*1024;
 	struct kinfo_proc *kp;
 
@@ -2421,20 +2427,24 @@
 	if (!job_assumes(j, (kp = malloc(len)) != NULL)) {
 		return;
 	}
-	if (!job_assumes(j, sysctl(mib, 3, kp, &len, NULL, 0) != -1)) {
+	if (!job_assumes(j, sysctl(mib, mib_sz, kp, &len, NULL, 0) != -1)) {
 		goto out;
 	}
 
 	kp_cnt = len / sizeof(struct kinfo_proc);
 
 	for (i = 0; i < kp_cnt; i++) {
+#ifndef KERN_PROC_PPID
 		if (kp[i].kp_eproc.e_ppid != j->p) {
 			continue;
-		} else if (kp[i].kp_proc.p_flag & P_EXEC) {
+		}
+#endif
+		if (kp[i].kp_proc.p_flag & P_EXEC) {
 			continue;
 		}
 
 		job_log(j, LOG_APPLEONLY, "Performance and sanity: fork() without exec*(). Please switch to posix_spawn()");
+		break;
 	}
 
 out:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080123/b9b25858/attachment.html


More information about the launchd-changes mailing list