Subject: Re: Time to fix a 25 year old misdesign
To: None <tech-kern@netbsd.org>
From: Lennart Augustsson <lennart@augustsson.net>
List: tech-kern
Date: 10/15/2000 20:10:01
Lennart Augustsson wrote:
> The old UNIX device driver interface is fundamentally broken. The
> problem is the following
>
> The driver routine open() is called every time the device
> is opened, but close() is only called on the last close.
I just checked something that I suspected was a consequence of the
fact stated above.
Most (all?) drivers that implement SIGIO are broken.
When a driver gets told that a process wants to get a SIGIO signal
when I/O is possible it saves a reference to the process (either a
pointer into the process table or a pid). When I/O is possible it will
send a signal to that process.
Here's what can happen: A process opens a device and tells the driver
it want's SIGIO notification. It then forks and exits. Since the
driver is not notified that the original process has closed its descriptor
it keeps the reference to the original process. When this reference
(proc pointer or pid) gets reused a totally unsuspecting process can
get the signal.
I don't see how to implement this right unless the driver gets notified
on each close so it can drop the reference to the process.
Am I mistaken, or has SIGIO been broken since its inception?
(I could be mistaken, I've had enough coffee today. :)
--
-- Lennart