[vlc-devel] [PATCH] Don't assume O_CLOEXEC is defined

Rafaël Carré funman at videolan.org
Wed Jan 4 20:11:36 CET 2012


---
 modules/access/dtv/linux.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index 4bbef3f..5a129ef 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -56,9 +56,13 @@
 static int dvb_open_adapter (uint8_t adapter)
 {
     char dir[20];
+    int flags = O_SEARCH | O_DIRECTORY;
+#ifdef O_CLOEXEC
+    flags |= O_CLOEXEC;
+#endif
 
     snprintf (dir, sizeof (dir), "/dev/dvb/adapter%"PRIu8, adapter);
-    return open (dir, O_SEARCH|O_DIRECTORY|O_CLOEXEC);
+    return open (dir, flags);
 }
 
 /** Opens the DVB device node of the specified type */
@@ -67,8 +71,12 @@ static int dvb_open_node (int dir, const char *type, unsigned dev, int flags)
     int fd;
     char path[strlen (type) + 4];
 
+#ifdef O_CLOEXEC
+    flags |= O_CLOEXEC;
+#endif
+
     snprintf (path, sizeof (path), "%s%"PRIu8, type, dev);
-    fd = openat (dir, path, flags|O_CLOEXEC);
+    fd = openat (dir, path, flags);
     if (fd != -1)
         fcntl (fd, F_SETFL, fcntl (fd, F_GETFL) | O_NONBLOCK);
     return fd;
-- 
1.7.7.3



More information about the vlc-devel mailing list