]> git.sesse.net Git - vlc/commitdiff
Win32: set close-on-exec where applicable
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 20 Sep 2012 15:49:42 +0000 (18:49 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 20 Sep 2012 15:58:30 +0000 (18:58 +0300)
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.

src/win32/filesystem.c

index 0a2644bc7abd8f582f22dc92b1ce7d8b862f01f7..a9d08090f554caf95321ba5817a61083102c5891 100644 (file)
@@ -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>