All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] alsa-lib leaves sound device open for child processes
@ 2003-02-03 22:16 Sebastian Kapfer
  2003-02-05 11:20 ` Jaroslav Kysela
  0 siblings, 1 reply; 25+ messages in thread
From: Sebastian Kapfer @ 2003-02-03 22:16 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]


The alsa-lib doesn't set the close-on-exec flag on its PCM device FD's.
The consequence is that processes spawned by alsa-lib clients inherit an
open file handle to the PCM device and thereby block it.

For example, mplayer can disable and re-launch the xscreensaver daemon.
In the alsa-enabled version of mplayer, the xscreensaver process
inherits a pcm handle, although xss can't make use of it. This
effectively forces me to restart xss manually after each mplayer
session.

Suggested fix:

--- src/pcm/pcm_hw.c.orig	2002-10-12 13:49:54.000000000 +0200
+++ src/pcm/pcm_hw.c	2003-02-03 23:07:14.000000000 +0100
@@ -867,6 +867,11 @@
 		ret = -errno;
 		goto _err;
 	}
+	if( fcntl( fd, F_SETFD, FD_CLOEXEC ) != 0 ) {
+		SYSERR("fcntl FD_CLOEXEC failed");
+		ret = -errno;
+		goto _err;
+	}
 	if (ioctl(fd, SNDRV_PCM_IOCTL_PVERSION, &ver) < 0) {
 		SYSERR("SNDRV_PCM_IOCTL_PVERSION failed");
 		ret = -errno;

-- 
Best Regards,   |   Hi! I'm a .signature virus. Copy me into
 Sebastian      |   your ~/.signature to help me spread!

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [BUG] alsa-lib leaves sound device open for child processes
@ 2003-02-05 18:50 Chris Rankin
  0 siblings, 0 replies; 25+ messages in thread
From: Chris Rankin @ 2003-02-05 18:50 UTC (permalink / raw)
  To: Paul Davis
  Cc: Takashi Iwai, Jaroslav Kysela, Sebastian Kapfer,
	alsa-devel@lists.sourceforge.net

Fair enough, but my point is that I'd expect the
close-on-exec flag NOT to be set unless I explicitly
set it myself. Same as with every other way of getting
a file descriptor.

Chris

 --- Paul Davis <paul@linuxaudiosystems.com> wrote: >
>Speaking as a userspace developer, I expect file
> >descriptors to be inherited by child processes
> unless
> >I explicitly request otherwise. Yes, I usually make
> >sure that I *DO* request otherwise, but that's not
> the
> >point...
> 
> the question is not about inheritance by child
> processes. its about
> close-on-exec behaviour. nobody is proposing any
> change to the
> situation after a simple fork(2).
> 
> --p 

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

^ permalink raw reply	[flat|nested] 25+ messages in thread
[parent not found: <20030205205905.7800db0c.sebastian_kapfer@web.de>]
* Re: [BUG] alsa-lib leaves sound device open for child processes
@ 2003-02-07 19:35 Chris Rankin
  0 siblings, 0 replies; 25+ messages in thread
From: Chris Rankin @ 2003-02-07 19:35 UTC (permalink / raw)
  To: Paul Davis; +Cc: alsa-devel

 --- Paul Davis <paul@linuxaudiosystems.com> wrote:
> not clearly so. there are very few resources
> accessed via a file
> descriptor that require this being done.

You think? Try unmounting a filesystem or unloading
the ide-cd kernel module if (say) xscreensaver has
been spawned by (say) xine, but xine has carelessly
leaked a file descriptor to a movie file, DVD device
etc. (But not with current versions of xine... ;-)

> the fact that an application has to understand this
> only adds to the
> problems with the block-on-open design.

Save me from application programmers who don't
understand what they're doing... ;-/!

Chris


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2003-02-12 12:46 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-03 22:16 [BUG] alsa-lib leaves sound device open for child processes Sebastian Kapfer
2003-02-05 11:20 ` Jaroslav Kysela
2003-02-05 12:42   ` Takashi Iwai
2003-02-05 13:05     ` Jaroslav Kysela
2003-02-05 13:55       ` Takashi Iwai
2003-02-05 14:03         ` Chris Rankin
2003-02-05 14:16           ` Paul Davis
  -- strict thread matches above, loose matches on Subject: below --
2003-02-05 18:50 Chris Rankin
     [not found] <20030205205905.7800db0c.sebastian_kapfer@web.de>
2003-02-05 22:39 ` Chris Rankin
2003-02-06 14:40   ` Sebastian Kapfer
2003-02-06 23:10     ` Chris Rankin
2003-02-07 13:03       ` Paul Davis
2003-02-07 13:58         ` Chris Rankin
2003-02-07 15:22           ` Paul Davis
2003-02-07 16:13           ` Takashi Iwai
2003-02-07 19:54             ` Chris Rankin
2003-02-07 14:37       ` Sebastian Kapfer
2003-02-07 19:46         ` Chris Rankin
2003-02-08 11:50           ` Jaroslav Kysela
2003-02-08 13:55             ` Sebastian Kapfer
2003-02-08 19:45             ` Sebastian Kapfer
2003-02-08 19:53               ` Jaroslav Kysela
2003-02-12 11:54                 ` Takashi Iwai
2003-02-12 12:46                   ` Jaroslav Kysela
2003-02-07 19:35 Chris Rankin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.