ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184
Rep:
driver close function not being call until munmap
I'm writing a driver and a userspace test application. I have ran into some what of an issue. When I open a file, and do a mmap using that file descriptor then close the file descriptor, my driver's close function is not called until I do a munmap on the address received from the mmap.
Can someone explain to me why this is, and if there is a way to instantly get the close call to my driver (like it normally does when not doing a mmap) prior to performing the munmap?
I'm writing a driver and a userspace test application. I have ran into some what of an issue. When I open a file, and do a mmap using that file descriptor then close the file descriptor, my driver's close function is not called until I do a munmap on the address received from the mmap.
Can someone explain to me why this is, and if there is a way to instantly get the close call to my driver (like it normally does when not doing a mmap) prior to performing the munmap?
I'm not familiar with driver programming, but is it possible to capture SIGs like you can in a userspace program? If so, you can try writing a handler for a specific SIG.
Think about it ... if you have mapped memory using a file-descriptor, then it does not make any sense at all to dismiss the driver until the memory has been unmapped. You've just pulled the rug out from underneath the ming vase.
Really, it surprises me that the attempt to close the file-descriptor did not throw an error ... did you check to see if it did?
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184
Original Poster
Rep:
Quote:
Originally Posted by sundialsvcs
Think about it ... if you have mapped memory using a file-descriptor, then it does not make any sense at all to dismiss the driver until the memory has been unmapped. You've just pulled the rug out from underneath the ming vase.
Really, it surprises me that the attempt to close the file-descriptor did not throw an error ... did you check to see if it did?
I did check the return value of the close call and there is no error. I too am surprised that file descriptor close does not return an error, given the behavior.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.