Re: Unloading a KEXT with Client still connected
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com -josh On Jul 13, 2005, at 1:42 PM, Peter Lovell wrote: On Jul 13, 2005, at 4:25 PM, Allan Hoeltje wrote: Is there some way I can handle this? -Allan This email sent to jgraessley@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com Peter is correct. To elaborate further, I assume you're using a kernel control socket to communicate with your kext? When your kext's unload function is called, you need to unregister any filters, interfaces, and kernel control sockets you have registered. To unregister a kernel control socket, use the function ctl_deregister. This function will return an error if a client is connected. If this function returns an error, your kernel unload function should return KERN_FAILURE. When shutting down or restarting, a non-IOKit kext will not be unloaded automatically, so you will not get a panic if your client is still connected. Thank you all for coping with my continuous stream of newbie questions, hopefully including this one: I have a client application that connects to my KEXT and I am currently testing the KEXT by using kextload and kextunload. I noticed the hard way that if I kextunload the KEXT while my client is running and connected I get the scary "gray curtain of death" - which I guess is the kernel panic everybody refers to. Eventually my KEXT will be put in the startup folder. If the user shuts down with the client still running and connected to the KEXT will I get a kernel panic? I have looked at the XNU source code (thank you Justin!) and thought maybe there was some way for a KEXT to force close all client connections but found none. Your kext can, and probably should, refuse to unload if there are connections open. Try to think of the kext as a servant and look at the close-down sequence from the other direction. Your kext should stay there until its client (the application, or whatever) closes, and then you can unload. Don't try to close anything from your kext, but instead get the application to close the connection, with a little "help" if necessary. Cheers.....Peter _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/jgraessley% 40apple.com smime.p7s
participants (1)
-
Josh Graessley