Changeset 23512
- Timestamp:
- 02/06/08 18:15:19 (10 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/SULeopard/launchd/src/launchd_core_logic.c
r23499 r23512 463 463 static void extract_rcsid_substr(const char *i, char *o, size_t osz); 464 464 static void do_first_per_user_launchd_hack(void); 465 static size_t get_kern_max_proc(void); 465 466 static void do_file_init(void) __attribute__((constructor)); 466 467 467 468 /* file local globals */ 469 static bool do_apple_internal_magic; 468 470 static size_t total_children; 469 471 static size_t total_anon_children; … … 2047 2049 { 2048 2050 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PGRP, j->p }; 2049 size_t i, kp_cnt, len = 10*1024*1024;2051 size_t i, kp_cnt, len = sizeof(struct kinfo_proc) * get_kern_max_proc(); 2050 2052 struct kinfo_proc *kp; 2053 2054 #if TARGET_OS_EMBEDDED 2055 if (!do_apple_internal_magic) { 2056 return; 2057 } 2058 #endif 2051 2059 2052 2060 if (!job_assumes(j, (kp = malloc(len)) != NULL)) { … … 2822 2830 { 2823 2831 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; 2824 size_t i, kp_cnt, len = 10*1024*1024;2825 struct kinfo_proc *kp = malloc(len);2832 size_t i, kp_cnt, len = sizeof(struct kinfo_proc) * get_kern_max_proc(); 2833 struct kinfo_proc *kp; 2826 2834 uid_t u = j->mach_uid; 2835 2836 #if TARGET_OS_EMBEDDED 2837 if (!do_apple_internal_magic) { 2838 return; 2839 } 2840 #endif 2841 kp = malloc(len); 2827 2842 2828 2843 if (!job_assumes(j, kp != NULL)) { … … 4303 4318 { 4304 4319 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; 4305 size_t i, kp_cnt, len = 10*1024*1024;4320 size_t i, kp_cnt, len = sizeof(struct kinfo_proc) * get_kern_max_proc(); 4306 4321 struct kinfo_proc *kp; 4307 4322 4323 #if TARGET_OS_EMBEDDED 4324 if (!do_apple_internal_magic) { 4325 return; 4326 } 4327 #endif 4308 4328 if (jm->parentmgr || getpid() != 1) { 4309 4329 return; … … 6779 6799 } 6780 6800 6801 size_t 6802 get_kern_max_proc(void) 6803 { 6804 int mib[] = { CTL_KERN, KERN_MAXPROC }; 6805 int max = 100; 6806 size_t max_sz = sizeof(max); 6807 6808 launchd_assumes(sysctl(mib, 2, &max, &max_sz, NULL, 0) != -1); 6809 6810 return max; 6811 } 6812 6781 6813 void 6782 6814 do_file_init(void) 6783 6815 { 6816 struct stat sb; 6817 6784 6818 launchd_assert(mach_timebase_info(&tbi) == 0); 6785 6819 6786 } 6820 if (stat("/AppleInternal", &sb) == 0) { 6821 do_apple_internal_magic = true; 6822 } 6823 }

