[vlc-devel] commit: open: O_CLOEXEC is ignored by older kernel, fix & simplify ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Nov 4 20:46:27 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov  4 21:45:58 2009 +0200| [6dc14523d72c30a91bd03e69f7e8a4df94584218] | committer: Rémi Denis-Courmont 

open: O_CLOEXEC is ignored by older kernel, fix & simplify

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6dc14523d72c30a91bd03e69f7e8a4df94584218
---

 src/text/filesystem.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/text/filesystem.c b/src/text/filesystem.c
index f6bab4a..35f93cd 100644
--- a/src/text/filesystem.c
+++ b/src/text/filesystem.c
@@ -99,6 +99,10 @@ int utf8_open (const char *filename, int flags, ...)
         mode = va_arg (ap, unsigned int);
     va_end (ap);
 
+#ifdef O_CLOEXEC
+    flags |= O_CLOEXEC;
+#endif
+
 #ifdef UNDER_CE
     /*_open translates to wchar internally on WinCE*/
     return _open (filename, flags, mode);
@@ -119,22 +123,11 @@ int utf8_open (const char *filename, int flags, ...)
         return -1;
     }
 
-    int fd;
-
-#ifdef O_CLOEXEC
-    fd = open (local_name, flags | O_CLOEXEC, mode);
-    if (fd == -1 && errno == EINVAL)
-#endif
-    {
-        fd = open (local_name, flags, mode);
+    int fd = open (local_name, flags | O_CLOEXEC, mode);
 #ifdef HAVE_FCNTL
-        if (fd != -1)
-        {
-            int flags = fcntl (fd, F_GETFD);
-            fcntl (fd, F_SETFD, FD_CLOEXEC | ((flags != -1) ? flags : 0));
-        }
+    if (fd != -1)
+        fcntl (fd, F_SETFD, FD_CLOEXEC);
 #endif
-    }
 
     LocaleFree (local_name);
     return fd;




More information about the vlc-devel mailing list