Unix Process ID (and Processes List)
Unix Process ID (and Processes List)
- Subject: Unix Process ID (and Processes List)
- From: "Daniele M." <email@hidden>
- Date: Tue, 4 Mar 2003 23:21:06 +0100
- Organization: westcode software, inc.
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.processName,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.