> Good question. If the blocking in the driver is handled with a > wait_event_interruptible, ctrl-c interrupts that, the blocked I/O > releases, and (I think) everything cleans up nicely and the driver can > be unloaded. With that in mind, how can I tell if I have memory leaks > after the app has shut down? It sounds like if Ctrl+C is working for you, then you're in good shape. Ctrl+C is just a signal (SIGINT if I'm not mistaken). > The biggest concern that I have is that the user app crashes and can not > send/do anything. My driver is still hanging out trying to service the > blocked request. Under those circumstances I have two concerns. What > happens if the app is dead and gone and the driver finally unblocks and > tries a copy_to_user. Understand that the kernel/your driver is executing on behalf of your userspace app. When the driver is working, your process is blocked. When a signal arrives, the driver unblocks due to the signal (assuming your waiting with an interruptible event) and returns control to userspace. Your app can then crash and the driver is fine. You just have to close the file descriptor (which should happen automatically even if your program crashes). > Secondly if the driver never gets whatever it is > waiting for to unblock, it can't be unloaded because it thinks it is > busy. What if a user then restarts the app and in comes another request > that will be blocked. I have tried to make this reentrant, but at this > point life is getting messy. If the driver never unblocks, then your app is still blocked. Your app can't crash without the driver unblocking. > Lastly, if the app is nicely asked to shutdown, how should it tell the > driver to unblock? If a signal is the answer, what kind? I am using > pthread here(in fact the blocked reqeusts are ioctl requests from > threads spawned off of the main application). SIGTERM is probably what you want since that's what Linux uses when the system goes down for reboot/halt. The driver will unblock on the signal and return control to userspace. As long as your open/close increment/decrement the use count or you use the MODULE_OWNER macro (which I think is preferred), you should be fine as far as being able to load/unload your module. -- John Tyner jtyner@cs.ucr.edu -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ IRC Channel: irc.openprojects.net / #kernelnewbies Web Page: http://www.kernelnewbies.org/