summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/open.c
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2013-08-28 17:10:04 +0000
committerAlain Frisch <alain@frisch.fr>2013-08-28 17:10:04 +0000
commit842f6794a956a726f73e9beb63e679cf7a9d679b (patch)
treee7417d4fcd7c56c84858a9e23f2a2228ee8e3462 /otherlibs/win32unix/open.c
parentb0d5fc28a26e5a35ed8513ce939a5dd8e1a21a0d (diff)
parenta18853fde97e44a7ff21184c77998f94edfa14f7 (diff)
Synchronize with trunk.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@14042 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/open.c')
-rw-r--r--otherlibs/win32unix/open.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/otherlibs/win32unix/open.c b/otherlibs/win32unix/open.c
index 40ea34b63..a2ffa4e1e 100644
--- a/otherlibs/win32unix/open.c
+++ b/otherlibs/win32unix/open.c
@@ -16,22 +16,26 @@
#include "unixsupport.h"
#include <fcntl.h>
-static int open_access_flags[13] = {
+static int open_access_flags[14] = {
GENERIC_READ, GENERIC_WRITE, GENERIC_READ|GENERIC_WRITE,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-static int open_create_flags[13] = {
- 0, 0, 0, 0, 0, O_CREAT, O_TRUNC, O_EXCL, 0, 0, 0, 0, 0
+static int open_create_flags[14] = {
+ 0, 0, 0, 0, 0, O_CREAT, O_TRUNC, O_EXCL, 0, 0, 0, 0, 0, 0
};
-static int open_share_flags[13] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FILE_SHARE_DELETE
+static int open_share_flags[14] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FILE_SHARE_DELETE, 0
+};
+
+static int open_cloexec_flags[14] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
};
CAMLprim value unix_open(value path, value flags, value perm)
{
- int fileaccess, createflags, fileattrib, filecreate, sharemode;
+ int fileaccess, createflags, fileattrib, filecreate, sharemode, cloexec;
SECURITY_ATTRIBUTES attr;
HANDLE h;
@@ -55,9 +59,10 @@ CAMLprim value unix_open(value path, value flags, value perm)
else
fileattrib = FILE_ATTRIBUTE_NORMAL;
+ cloexec = convert_flag_list(flags, open_cloexec_flags);
attr.nLength = sizeof(attr);
attr.lpSecurityDescriptor = NULL;
- attr.bInheritHandle = TRUE;
+ attr.bInheritHandle = cloexec ? FALSE : TRUE;
h = CreateFile(String_val(path), fileaccess,
sharemode, &attr,