- CFMachPortContext termcb_contextinfo;
- termcb_contextinfo.version = NULL;
- termcb_contextinfo.info = (void*)proc_data;
- termcb_contextinfo.retain = NULL;
- termcb_contextinfo.release = NULL;
- termcb_contextinfo.copyDescription = NULL;
- CFMachPortRef CFMachPortForProcess;
- Boolean ShouldFreePort;
- CFMachPortForProcess = CFMachPortCreateWithPort(NULL, machPortForProcess, NULL, &termcb_contextinfo, &ShouldFreePort);
- if(!CFMachPortForProcess)
- {
- wxLogDebug(wxT("No CFMachPortForProcess"));
- mach_port_deallocate(taskOfOurProcess, machPortForProcess);
- return -1;
- }
- if(ShouldFreePort)
- {
- kernResult = mach_port_deallocate(taskOfOurProcess, machPortForProcess);
- if(kernResult!=KERN_SUCCESS)
- {
- wxLogDebug(wxT("Couldn't deallocate mach port"));
- return -1;
- }
- }
- CFMachPortSetInvalidationCallBack(CFMachPortForProcess, &wxMAC_MachPortEndProcessDetect);
- CFRunLoopSourceRef runloopsource;
- runloopsource = CFMachPortCreateRunLoopSource(NULL,CFMachPortForProcess, (CFIndex)0);
- if(!runloopsource)
- {
- wxLogDebug(wxT("Couldn't create runloopsource"));
- return -1;
- }
-
- CFRelease(CFMachPortForProcess);