[alsa-devel] [PATCH 1/3] Open device nodes with close-on-exec flag

Takashi Iwai tiwai at suse.de
Fri Nov 6 11:06:41 CET 2009


At Thu,  5 Nov 2009 21:17:40 +0200,
Rémi Denis-Courmont wrote:
> 
> Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> ---
>  include/local.h |   17 +++++++++++------
>  1 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/include/local.h b/include/local.h
> index b5a1c45..afc4acd 100644
> --- a/include/local.h
> +++ b/include/local.h
> @@ -230,22 +230,27 @@ extern snd_lib_error_handler_t snd_err_msg;
>  # define link_warning(symbol, msg)
>  #endif
>  
> -/* open with resmgr */
> -#ifdef SUPPORT_RESMGR
>  static inline int snd_open_device(const char *filename, int fmode)
>  {
> +#ifdef O_CLOEXEC
> +	int fd = open(filename, fmode|O_CLOEXEC);
> +#else
>  	int fd = open(filename, fmode);
> -	if (fd >= 0)
> +#endif
> +	if (fd >= 0) {
> +		fcntl(fd, F_SETFD, FD_CLOEXEC);
>  		return fd;
> +	}
> +
> +/* open with resmgr */
> +#ifdef SUPPORT_RESMGR
>  	if (errno == EAGAIN || errno == EBUSY)
>  		return fd;
>  	if (! access(filename, F_OK))
>  		return rsm_open_device(filename, fmode);
> +#endif
>  	return -1;
>  }
> -#else
> -#define snd_open_device(filename, fmode) open(filename, fmode);
> -#endif

CLOEXEC stuff should be applied to the case with resmgr as well.
Care to rewrite the patch?


thanks,

Takashi


More information about the Alsa-devel mailing list