2008-09-25 07:44:39     sometimes close(Fd) does not enter into close function of Drivers

Document created by Aaronwu Employee on Aug 7, 2013
Version 1Show Document
  • View in full screen mode

2008-09-25 07:44:39     sometimes close(Fd) does not enter into close function of Drivers

svs k (INDIA)

Message: 62702   

 

Hi All,

 

         I m using a custom BF533 board. I m working in uClinux 2007R1-Rc3 distribution. I created a new lcd driver for my board. I could find, close(FD) called from Application is not entering into close function defined in my driver sometimes. I added few printk statements in driver close() function. But sometimes, they are displayed in console ofcourse sometimes, no statement could be seen in console.

 

May i know why this is happening?

 

 

 

 

 

Thanks,

 

svsk

QuoteReplyEditDelete

 

 

2008-09-26 04:51:50     Re: sometimes close(Fd) does not enter into close function of Drivers

Yi Li (CHINA)

Message: 62783   

 

If you want to debug the kernel, you may found the answer:

 

http://docs.blackfin.uclinux.org/doku.php?id=kernel_debugging

 

 

 

 

QuoteReplyEditDelete

 

 

2008-09-30 06:21:21     Re: sometimes close(Fd) does not enter into close function of Drivers

Michael McTernan (UNITED KINGDOM)

Message: 62924   

 

I think there are a couple of case where this can happen.  One is if the process has called fork() or dup() in which case each process or filedescriptor must be closed before the driver release function get called (you may need to use fcntl() to set close-on-exec for some fds if forking to exec() a subprocess).  I think the other case is that some code is blocking in the driver somewhere (e.g. on a blocking read() or similar) while some other thread attempts to close the fd.  In such a case the release() function of the driver will be called only when all the system calls have completed.

 

You may find listing the output of /proc/*/fd/ useful in find the processes/threads that have file descriptors for some device.

 

Hope that helps,

 

Mike

Attachments

    Outcomes