diff options
Diffstat (limited to 'otherlibs/win32unix')
-rw-r--r-- | otherlibs/win32unix/open.c | 21 | ||||
-rw-r--r-- | otherlibs/win32unix/unix.ml | 1 |
2 files changed, 14 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, diff --git a/otherlibs/win32unix/unix.ml b/otherlibs/win32unix/unix.ml index a8a3dcc2a..cff003994 100644 --- a/otherlibs/win32unix/unix.ml +++ b/otherlibs/win32unix/unix.ml @@ -169,6 +169,7 @@ type open_flag = | O_SYNC | O_RSYNC | O_SHARE_DELETE + | O_CLOEXEC type file_perm = int |