LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-30-2011, 11:53 AM   #1
dbrazeau
Member
 
Registered: Aug 2009
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184

Rep: Reputation: 28
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?
 
Old 07-02-2011, 08:23 AM   #2
raevin
Member
 
Registered: Jul 2004
Distribution: Arch Linux, Ubuntu
Posts: 80

Rep: Reputation: 16
Quote:
Originally Posted by dbrazeau View Post
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.
 
Old 07-03-2011, 11:57 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
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?
 
Old 07-06-2011, 11:07 AM   #4
dbrazeau
Member
 
Registered: Aug 2009
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184

Original Poster
Rep: Reputation: 28
Quote:
Originally Posted by sundialsvcs View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
who will call the probe function of the pci driver in x86 processor joslyn Linux - Software 0 05-17-2010 07:24 AM
How can we access driver function using system call ? bkankru Linux - General 4 04-16-2010 03:39 AM
Suse Enterprise Server 11: ifconfig does not call my Network driver's open function pvpnguyen Programming 1 09-03-2009 04:21 PM
function use to determine if a dvd-driver tray is close jaepi Linux - Hardware 2 05-30-2007 08:46 PM
USB driver won't call probe function linux=future Linux - Kernel 2 01-13-2007 04:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration