diff options
Diffstat (limited to 'otherlibs/win32unix/open.c')
-rw-r--r-- | otherlibs/win32unix/open.c | 21 |
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, |