Re: Unix Process ID (and Processes List)
Re: Unix Process ID (and Processes List)
- Subject: Re: Unix Process ID (and Processes List)
- From: Bill Cheeseman <email@hidden>
- Date: Tue, 04 Mar 2003 17:57:18 -0500
on 03-03-04 5:21 PM, Daniele M. at email@hidden wrote:
>
I would to know the Unix ID number of a process. I have found the code
>
to get the processes list. Is there a method to get, from here, the
>
unix pid of the process?
Once you have the process serial number (psn) of a process (as you do in the
code you found), you can get its process identification number (pid) in a
number of ways. The easiest is the GetProcessPid function in process.h --
feed it the psn, and it spits back the pid.
You might want to modify the code you found so that, instead of returning an
array of all the running processes, you just look for the particular process
you want and break immediately when it's found (you don't say what criterion
you're using), then call GetProcessPid with the psn of the process you
wanted.
If the process you care about is an application process having a GUI and you
know, say, its path or name, you can get its pid all in Cocoa with some of
the methods in NSWorkspace, without having to drop into the Carbon or system
functions.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.