1996-09-04 07:17:43 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Objective Caml */
|
|
|
|
/* */
|
|
|
|
/* Xavier Leroy and Pascal Cuoq, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
1996-09-04 07:17:43 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include <mlvalues.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include "unixsupport.h"
|
|
|
|
|
1997-09-03 07:38:02 -07:00
|
|
|
int win_set_inherit(value fd, BOOL inherit)
|
1996-09-17 07:43:05 -07:00
|
|
|
{
|
|
|
|
HANDLE oldh, newh;
|
1997-09-03 07:38:02 -07:00
|
|
|
|
|
|
|
oldh = Handle_val(fd);
|
1996-09-09 08:02:35 -07:00
|
|
|
if (! DuplicateHandle(GetCurrentProcess(), oldh,
|
1997-05-19 08:42:21 -07:00
|
|
|
GetCurrentProcess(), &newh,
|
1997-09-03 07:38:02 -07:00
|
|
|
0L, inherit, DUPLICATE_SAME_ACCESS)) {
|
2001-08-28 07:47:48 -07:00
|
|
|
win32_maperr(GetLastError());
|
1996-09-09 08:02:35 -07:00
|
|
|
return -1;
|
|
|
|
}
|
1997-09-03 07:38:02 -07:00
|
|
|
Handle_val(fd) = newh;
|
|
|
|
CloseHandle(oldh);
|
|
|
|
return 0;
|
1996-09-09 08:02:35 -07:00
|
|
|
}
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value win_set_close_on_exec(value fd)
|
1996-09-09 08:02:35 -07:00
|
|
|
{
|
1997-09-03 07:38:02 -07:00
|
|
|
if (win_set_inherit(fd, FALSE) == -1) uerror("set_close_on_exec", Nothing);
|
1996-09-09 08:02:35 -07:00
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value win_clear_close_on_exec(value fd)
|
1996-09-09 08:02:35 -07:00
|
|
|
{
|
1997-09-03 07:38:02 -07:00
|
|
|
if (win_set_inherit(fd, TRUE) == -1) uerror("clear_close_on_exec", Nothing);
|
1996-09-04 07:17:43 -07:00
|
|
|
return Val_unit;
|
|
|
|
}
|