Re: Process Termination Detection
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On 2008-11-14, at 14:11:16, Brian McKinnon wrote: The two solutions I have found so far are as follows. Solution 1: API: Posix Solution 2: API: mach kqueue with EVFILT_PROC and NOTE_EXIT might be a possibility. Philip Aker echo astwta@lvpc.dslh@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... I am trying to find the best solution to the following problem. I would like to have process A be able to determine when process B has terminated. Process B does not necessarily have to be a child of process A. Any solutions in the mach, POSIX, BSD, Carbon or Cocoa layers would be considered. Poll using kill( pid, 0 ) and wait for an ESRCH error indicating that there is no process with the id 'pid'. This solution is not good because it requires frequent poling for the life of process B which may be long lived. It has the benefit that no special privileges are needed to execute it. Use task_for_pid( myTask, pid, &task ) to get a port on process B. Use mach_port_request_notification( myTask, task, MACH_NOTIFY_DEAD_NAME, 1, port, MACH_MSG_TYPE_MAKE_SEND_ONCE, &lastPort) to register a notification on the mach port 'port' when the mach port 'task' becomes a dead name. The drawbacks to this solution are that process A needs to be running as root, be in the group procmod or be digitally signed. It has the benefit that no polling is required. Are there any other solutions to this on Darwin? This email sent to site_archiver@lists.apple.com
participants (1)
-
Philip Aker