This is NSTask_accessing.m in view mode; [Download] [Up]
#import "NSTask_accessing.h"
#import <objc/objc-class.h>
// Mach only
#ifdef NeXT
#import <mach/mach.h>
#import <mach/mach_error.h>
#endif NeXT
@implementation NSTask (accessing)
- (int)pid
{
int pid;
object_getInstanceVariable(self, "_pid", (void**)&pid);
return pid;
}
- (void)kill
{
kill([self pid], 9);
return;
}
// Mach only
#ifdef NeXT
- (task_t)machTaskId
{
task_t task;
kern_return_t result;
result = task_by_unix_pid(task_self(), [self pid], &task);
if (result != KERN_SUCCESS)
{
// could not access the task - security violation?
mach_error("task_by_unix_pid", result);
return TASK_NULL;
}
else
{
// found the task
return task;
}
}
#endif NeXT
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.