| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| Hi Steve, On Jan 6, 2006, at 8:34 PM, Steve Checkoway wrote:
Two things: first, the sample is incorrect in that it's doing way too much work from a signal handler. This is a known problem and will be fixed in the next release of the sample. (Only certain functions are safe to call in a signal handler, and those are documented in sigaction(2).) Second, yes, you do need to destroy notification ports to avoid leaking. The general rule is that APIs with "Create" or "Copy" in the name hand you a new reference to something that you're expected to release when you're done with it. The API in this case is IONotificationPortCreate(), which fits the rule. To see the leak, comment out the IONotificationPortDestroy call and step through the sample in the debugger while watching the #PRTS column in top(1). The problem is how to call IONotificationPortDestroy safely from a command line tool that only terminates in response to a signal. One way is to do what is done in the CFLocalServer sample: Check out the InstallSignalToSocket routine in "Common.c" in that project. It creates a UNIX domain socket and has the signal handler write one end of the socket when it receives a signal. The read side of this socket is wrapped in a CFSocket. This allows you to transfer control from the signal handler to the runloop without doing illegal things in the signal handler. HTH, --gc __________________________________________________________________ Garth Cummings Apple Developer Technical Support email@hidden http://developer.apple.com/technicalsupport |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/email@hidden This email sent to email@hidden
| References: | |
| >IONotificationPortRef cleanup (From: Steve Checkoway <email@hidden>) |
| Home | Archives | FAQ | 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 © 2007 Apple Inc. All rights reserved.