Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Nov 2000 17:57:02 -0800 (PST)
From:      Luigi Rizzo <rizzo@aciri.org>
To:        bschwand@dvart.com (bruno schwander)
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: close call in a device ?
Message-ID:  <200011080157.RAA00555@iguana.aciri.org>
In-Reply-To: <3A08ACB5.FD22CE8@dvart.com> from bruno schwander at "Nov 7, 2000  5:30:29 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> when a process closes the device, I do not get a "close" call for each
> process closing the device. I instead get a close only on the last
> process closing the device.

the reason for this is that you might have a process fork() after
it has opened the device, and you do not want to get to the
device all close calls from all processes generated by the original
one, but really only the last instance.

The thing is, i think your model (allocating per-user resources on
open) is wrong. It cannot protect you from a process forking
and then having two instances using the same device.

If you want multiple instances of the device, one option could be
to use the minor number and really create multiple instances
of the device, and open them in exclusive way so you know that
there can be only one open per device (you should scan available
devices in a similar way as the one is used for scanning pty's).

	cheers
	luigi


----------------------------------+-----------------------------------------
 Luigi RIZZO, luigi@iet.unipi.it  . ACIRI/ICSI (on leave from Univ. di Pisa)
 http://www.iet.unipi.it/~luigi/  . 1947 Center St, Berkeley CA 94704
 Phone: (510) 666 2927
----------------------------------+-----------------------------------------
> This is a problem since I need to allocate/free resources for each
> process accessing the device, at the time a process closes the device.
> 
> Is there a way to make sure my driver gets all "close" calls ?
> 
> I could possibly get around this by using timeouts, but the
> unpredictability of the accessing processes may make this very difficult
> and suboptimal, so getting the "close" calls would be way better
> 
> Thank you all for any information on this
> 
> bruno
> 
> --
> 
> ###########################################################################
> 
>         Bruno Schwander
>         Senior Software Engineer
> 
>         Worldgate Communications, Inc
>         email: bschwand@dvart.com
> 
> ############################################################################
> 
> 
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message
> 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011080157.RAA00555>