[vlc-commits] Win32: set close-on-exec where applicable

Rémi Denis-Courmont git at videolan.org
Thu Sep 20 18:06:09 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Sep 20 18:49:42 2012 +0300| [b616a49004b8e992de38e334745ce90481e1596b] | committer: Rémi Denis-Courmont

Win32: set close-on-exec where applicable

It's called O_NOINHERIT, but it really is the same as O_CLOEXEC.
As with POSIX, there is no way to set it for dup()/dup2() though.

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

 src/win32/filesystem.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/win32/filesystem.c b/src/win32/filesystem.c
index 0a2644b..a9d0809 100644
--- a/src/win32/filesystem.c
+++ b/src/win32/filesystem.c
@@ -69,15 +69,16 @@ int vlc_open (const char *filename, int flags, ...)
     unsigned int mode = 0;
     va_list ap;
 
+    flags |= O_NOINHERIT; /* O_CLOEXEC */
+    /* Defaults to binary mode */
+    if ((flags & O_TEXT) == 0)
+        flags |= O_BINARY;
+
     va_start (ap, flags);
     if (flags & O_CREAT)
         mode = va_arg (ap, unsigned int);
     va_end (ap);
 
-    /* Defaults to binary mode */
-    if ((flags & O_TEXT) == 0)
-        flags |= O_BINARY;
-
     /*
      * open() cannot open files with non-“ANSI” characters on Windows.
      * We use _wopen() instead. Same thing for mkdir() and stat().
@@ -271,7 +272,7 @@ int vlc_dup (int oldfd)
 
 int vlc_pipe (int fds[2])
 {
-    return _pipe (fds, 32768, O_BINARY);
+    return _pipe (fds, 32768, O_NOINHERIT | O_BINARY);
 }
 
 #include <vlc_network.h>



More information about the vlc-commits mailing list