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

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 6 18:24:33 PST 2008


Revision: 23513
          http://trac.macosforge.org/projects/launchd/changeset/23513
Author:   zarzycki at apple.com
Date:     2008-02-06 18:24:32 -0800 (Wed, 06 Feb 2008)

Log Message:
-----------
<rdar://problem/5725563> Device hung on "slide to unlock" screen

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-02-07 02:15:19 UTC (rev 23512)
+++ trunk/launchd/src/launchd_core_logic.c	2008-02-07 02:24:32 UTC (rev 23513)
@@ -461,6 +461,7 @@
 static bool cronemu_min(struct tm *wtm, int min);
 
 /* miscellaneous file local functions */
+static size_t get_kern_max_proc(void);
 static void ensure_root_bkgd_setup(void);
 static int dir_has_files(job_t j, const char *path);
 static char **mach_cmd2argv(const char *string);
@@ -2104,9 +2105,15 @@
 job_log_stray_pg(job_t j)
 {
 	int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PGRP, j->p };
-	size_t i, kp_cnt, len = 10*1024*1024;
+	size_t i, kp_cnt, len = sizeof(struct kinfo_proc) * get_kern_max_proc();
 	struct kinfo_proc *kp;
 
+#if TARGET_OS_EMBEDDED
+	if (!do_apple_internal_logging) {
+		return;
+	}
+#endif
+
 	runtime_ktrace(RTKT_LAUNCHD_FINDING_STRAY_PG, j->p, 0, 0);
 
 	if (!job_assumes(j, (kp = malloc(len)) != NULL)) {
@@ -2417,7 +2424,7 @@
 	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;
+	size_t i, kp_cnt, len = sizeof(struct kinfo_proc) * get_kern_max_proc();
 	struct kinfo_proc *kp;
 
 	if (!do_apple_internal_logging || j->anonymous || j->per_user) {
@@ -2958,10 +2965,17 @@
 job_log_pids_with_weird_uids(job_t j)
 {
 	int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
-	size_t i, kp_cnt, len = 10*1024*1024;
-	struct kinfo_proc *kp = malloc(len);
+	size_t i, kp_cnt, len = sizeof(struct kinfo_proc) * get_kern_max_proc();
+	struct kinfo_proc *kp;
 	uid_t u = j->mach_uid;
 
+#if TARGET_OS_EMBEDDED
+	if (!do_apple_internal_logging) {
+		return;
+	}
+#endif
+	kp = malloc(len);
+
 	if (!job_assumes(j, kp != NULL)) {
 		return;
 	}
@@ -4464,9 +4478,15 @@
 jobmgr_log_stray_children(jobmgr_t jm)
 {
 	int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
-	size_t i, kp_cnt = 0, kp_skipped = 0, len = 10*1024*1024;
+	size_t i, kp_cnt = 0, kp_skipped = 0, len = sizeof(struct kinfo_proc) * get_kern_max_proc();
 	struct kinfo_proc *kp;
 
+#if TARGET_OS_EMBEDDED
+	if (!do_apple_internal_logging) {
+		return;
+	}
+#endif
+
 	if (likely(jm->parentmgr || !pid1_magic)) {
 		return;
 	}
@@ -6965,3 +6985,15 @@
 		}
 	} while ((returned == (sizeof(buf) / sizeof(buf[0]))) && (found > 0));
 }
+
+size_t
+get_kern_max_proc(void)
+{
+	int mib[] = { CTL_KERN, KERN_MAXPROC };
+	int max = 100;
+	size_t max_sz = sizeof(max);
+	
+	launchd_assumes(sysctl(mib, 2, &max, &max_sz, NULL, 0) != -1);
+	
+	return max;
+}

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


More information about the launchd-changes mailing list