Close never called. (Open same device file from 2 Apps.)

M. Warner Losh imp at bsdimp.com
Mon Dec 19 07:58:08 PST 2005


In message: <DFENKGMAOIJJBLCONJJPOEFMCDAA.hide_yama at jcom.home.ne.jp>
            "hide_yama" <hide_yama at jcom.home.ne.jp> writes:
:  Hi everybody
: 
: Now, I'm writing device driver on 5.4R. But it doesn't act that I
: unexpected.
: So, if you know the reason and the avoidance, please tell to me.
: Work is as follows.
: 
: 1) Open device file "/dev/mypci" by App1.
:    This App1 just calls open routine and sleep for a while in it's program.
: 
: 2) Open and close the same device file by App2 befor App1 is expired.
:    App2 calls just open and close routines in it's program.
: 
: I expect that App2 calls open and close routines, however App2 just calls
: open, doesn't call close.
: 
: Why isn't the close routine called?

Because close is only called on the last close.

: And are there any avoidance for this problem?

D_TRACKCLOSE in d_flags will change the behavior.

Warner


More information about the freebsd-drivers mailing list