From owner-freebsd-hackers Sun Oct 12 05:44:38 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id FAA18768 for hackers-outgoing; Sun, 12 Oct 1997 05:44:38 -0700 (PDT) (envelope-from owner-freebsd-hackers) Received: from word.smith.net.au (word.smith.net.au [202.0.75.3]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id FAA18762 for ; Sun, 12 Oct 1997 05:44:31 -0700 (PDT) (envelope-from mike@word.smith.net.au) Received: from word.smith.net.au (localhost.smith.net.au [127.0.0.1]) by word.smith.net.au (8.8.7/8.8.5) with ESMTP id WAA01285; Sun, 12 Oct 1997 22:11:13 +0930 (CST) Message-Id: <199710121241.WAA01285@word.smith.net.au> X-Mailer: exmh version 2.0zeta 7/24/97 To: Luigi Rizzo cc: hackers@FreeBSD.ORG, tlambert@primenet.com Subject: Re: catching signals... In-reply-to: Your message of "Sun, 12 Oct 1997 11:28:14 +0100." <199710121028.LAA03127@labinfo.iet.unipi.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 12 Oct 1997 22:11:13 +0930 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > normally, a close() on the audio device will patiently wait for data in > the playout queue to be consumed before returning. However, when a > process using the audio device is aborted with a signal, it would be > probably better to flush the output immediately rather than wait. > > The problem is, (1) how do I discriminate among these two situations > in the driver ? Is there any parameter in the call to close() which > allows me to make the distinction ? In your close(), you are using tsleep() to wait for a wakeup(), correct? Check the return value from tsleep() for EINTR to see if you have been hit by a signal. > Even worse, (2) what do I do when there are multiple references to the same > descriptor, and one is aborted ? Your close() won't be called until the _last_ close of the device. > Some time ago it was pointed out that the interface between the kernel > and the device driver does not notify the driver when a reference to > the device is lost, only when it is acquired through open(). So I guess > for (2) there is no hope to be able to do something sensible. Correct. > I am wondering, would it be reasonable to define and implement a new > interface in the device driver to notify the driver about processes who > reference them ? Multiple consumers should talk to the sound hardware via a multiplexer/ mixer of some sort, eg. nas or something better. There doesn't seem to be any other sensible way to multiplex multiple sound device consumers anyway. ie. what's the point of having a stream output device open by more than one consumer? mike