Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Retrieving process information without using ps



We are trying to port our application (http://www.cs.wisc.edu/condor) to OSX 
10.4 and are having trouble finding an alternative to task_for_pid() and 
task_info(). Condor uses the information provided by these to keep track of 
processes running on the execution nodes. On Linux, Solaris, and other 
systems, we usually retrieve this information from /proc.

I have been able to get almost all the information we need out of kinfo_proc 
returned from sysctl except for memory usage. Others have recommended that 
one pipes in the process information from 'ps':

http://lists.apple.com/archives/unix-porting/2006/Jan/msg00093.html

This is not a viable option because we there may be many processes spawned by 
a job and we will be calling this section of the code many times a minute. 
Calling 'ps' is significantly slower than accessing the internal data 
structures. In a simple test of 10,000 unique process lookups, using 
task_for_pid() is almost instantenous while 'ps' takes a full minute.

Note that this problem only occurs when the application's daemons are not run 
with root privileges. The system works fine when running as root, since we 
have the appropriate privileges to execute task_for_pid(). 

Is there a better/faster way to get process information in the new Intel OSX, 
in particular the image size and the resident set size, without using 'ps'? 
Or should we just tell our users to install our software and make sure that 
the appropriate user for the system is added to the procmod group?
--
Andy Pavlo
email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/unix-porting/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.