• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unix Process ID (and Processes List)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unix Process ID (and Processes List)


  • Subject: Re: Unix Process ID (and Processes List)
  • From: David Remahl <email@hidden>
  • Date: Tue, 4 Mar 2003 23:45:22 +0100

Taken vebatim from the header:

/*
* GetProcessPID()
*
* Summary:
* Get the UNIX process ID corresponding to a process.
*
* Discussion:
* Given a Process serial number, this call will get the UNIX
* process ID for that process. Note that this call does not make
* sense for Classic apps, since they all share a single UNIX
* process ID.
*
* Parameters:
*
* psn:
* Serial number of the target process
*
* pid:
* UNIX process ID of the process
*
* Availability:
* Mac OS X: in version 10.0 and later in ApplicationServices.framework
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
* Non-Carbon CFM: not available
*/
extern OSStatus
GetProcessPID(
const ProcessSerialNumber * psn,
pid_t * pid) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;

/ Rgds, David

On Tuesday, March 4, 2003, at 11:21 PM, Daniele M. wrote:

Hi

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?

- (NSArray *)Process {
NSMutableArray *resultsArray=[NSMutableArray array];
OSErr resultCode=noErr;
ProcessSerialNumber serialNumber;
ProcessInfoRec procInfo;
FSSpec appFSSpec;

Str255 procName;
serialNumber.highLongOfPSN = kNoProcess;
serialNumber.lowLongOfPSN = kNoProcess;

procInfo.processInfoLength =sizeof(ProcessInfoRec);
procInfo.processName=procName;
procInfo.processAppSpec = &appFSSpec;
procInfo.processAppSpec = &appFSSpec;

while (procNotFound != (resultCode =
GetNextProcess(&serialNumber))) {
if (noErr ==(resultCode =
GetProcessInformation(&serialNumber,&procInfo))) {
if (procName[1] == nil) procName[1] = '0';
[resultsArray
addObject:(NSString*)CFStringCreateWithPascalString(NULL,procInfo.proce ssName,kCFStringEncodingMacRoman)];
}
}
return resultsArray;
}


Thank you to all
Good work
dan
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Unix Process ID (and Processes List) (From: "Daniele M." <email@hidden>)

  • Prev by Date: Unix Process ID (and Processes List)
  • Next by Date: Re: Unix Process ID (and Processes List)
  • Previous by thread: Unix Process ID (and Processes List)
  • Next by thread: Re: Unix Process ID (and Processes List)
  • Index(es):
    • Date
    • Thread