1996-09-04 07:17:43 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
2011-07-27 07:17:02 -07:00
|
|
|
/* OCaml */
|
1996-09-04 07:17:43 -07:00
|
|
|
/* */
|
|
|
|
/* 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
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
#include <mlvalues.h>
|
|
|
|
#include "unixsupport.h"
|
2012-07-13 05:15:57 -07:00
|
|
|
#include <windows.h>
|
1996-09-04 07:17:43 -07:00
|
|
|
|
1997-09-03 07:38:02 -07:00
|
|
|
int win_set_inherit(value fd, BOOL inherit)
|
1996-09-17 07:43:05 -07:00
|
|
|
{
|
2011-12-20 00:59:09 -08:00
|
|
|
/* According to the MSDN, SetHandleInformation may not work
|
|
|
|
for console handles on WinNT4 and earlier versions. */
|
|
|
|
if (! SetHandleInformation(Handle_val(fd),
|
2012-07-30 11:04:46 -07:00
|
|
|
HANDLE_FLAG_INHERIT,
|
|
|
|
inherit ? HANDLE_FLAG_INHERIT : 0)) {
|
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
|
|
|
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;
|
|
|
|
}
|