|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Friday, January 17, 2003, at 02:58 PM, Ken Witzke wrote:
I perform cleanup at periodic intervals with code similar to that given below.In one tool, I used task_for_pid(mach_task_self(), pid, &pidMachPort) to get the mach port for the specified pid, then waited on an invalidation notification for the mach port. I used Cocoa to do it -- created an NSMachPort object with it, then listened for NSPortDidBecomeInvalidNotification -- although there are obviously lower-level interfaces too (mach_port_request_notification(), by the looks of it).
I need to keep track of the client PIDs that I need to clean up for.
It would be great if I could simply register with something for
notification of a PID going away.
This worked pretty well, although task_for_pid() fails if you are a non-privileged process trying to get the port for a privileged process. If your listener daemon is running as root though this shouldn't be a problem. I'm not sure how efficient this is, but it worked fine for the simple needs I had at the time.
| References: | |
| >Re: Detecting process (non-child) termination (From: Carl Lindberg <email@hidden>) |
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.