From: "Rémi Denis-Courmont" <remi@remlab.net>
To: alsa-devel@alsa-project.org
Subject: [PATCH 1/3] Open device nodes with close-on-exec flag
Date: Thu, 5 Nov 2009 21:17:40 +0200 [thread overview]
Message-ID: <1257448662-5124-1-git-send-email-remi@remlab.net> (raw)
In-Reply-To: <200911052116.53251.remi@remlab.net>
Signed-off-by: Rémi Denis-Courmont <remi@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
/* make local functions really local */
#define snd_dlobj_cache_lookup \
--
1.6.5.2
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2009-11-05 19:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 19:16 [PATCHv2 alsa-lib 0/3] Close-on-exec flag for device nodes Rémi Denis-Courmont
2009-11-05 19:17 ` Rémi Denis-Courmont [this message]
2009-11-06 10:06 ` [PATCH 1/3] Open device nodes with close-on-exec flag Takashi Iwai
2009-11-07 19:28 ` Rémi Denis-Courmont
2009-11-07 19:29 ` Rémi Denis-Courmont
2009-11-08 8:29 ` Takashi Iwai
2009-11-05 19:17 ` [PATCH 2/3] Remove old commented-out FD_CLOEXEC code Rémi Denis-Courmont
2009-11-05 19:17 ` [PATCH 3/3] Define _GNU_SOURCE so that <fcntl.h> gives O_CLOEXEC Rémi Denis-Courmont
2009-11-08 14:49 ` Lennart Poettering
2009-11-08 15:23 ` Rémi Denis-Courmont
2009-11-08 15:40 ` Lennart Poettering
-- strict thread matches above, loose matches on Subject: below --
2009-11-04 18:38 [RESEND] [PATCH 0/3] Close alsa-lib file descriptors on exec Rémi Denis-Courmont
2009-11-04 18:38 ` [PATCH 1/3] Open device nodes with close-on-exec flag Rémi Denis-Courmont
2009-11-04 19:03 ` Lennart Poettering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1257448662-5124-1-git-send-email-remi@remlab.net \
--to=remi@remlab.net \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox