1 /***********************************************************************/
5 /* Xavier Leroy and Pascal Cuoq, projet Cristal, INRIA Rocquencourt */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
12 /***********************************************************************/
14 /* $Id: close_on.c 4144 2001-12-07 13:41:02Z xleroy $ */
18 #include "unixsupport.h"
20 int win_set_inherit(value fd, BOOL inherit)
24 oldh = Handle_val(fd);
25 if (! DuplicateHandle(GetCurrentProcess(), oldh,
26 GetCurrentProcess(), &newh,
27 0L, inherit, DUPLICATE_SAME_ACCESS)) {
28 win32_maperr(GetLastError());
31 Handle_val(fd) = newh;
36 CAMLprim value win_set_close_on_exec(value fd)
38 if (win_set_inherit(fd, FALSE) == -1) uerror("set_close_on_exec", Nothing);
42 CAMLprim value win_clear_close_on_exec(value fd)
44 if (win_set_inherit(fd, TRUE) == -1) uerror("clear_close_on_exec", Nothing);