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 */
|
|
|
|
/* under the terms of the GNU Library General Public 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)) {
|
1996-09-17 07:43:05 -07:00
|
|
|
_dosmaperr(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
|
|
|
}
|
|
|
|
|
1997-09-03 07:38:02 -07:00
|
|
|
value win_set_close_on_exec(value fd) /* ML */
|
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;
|
|
|
|
}
|
|
|
|
|
1997-09-03 07:38:02 -07:00
|
|
|
value win_clear_close_on_exec(value fd) /* ML */
|
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;
|
|
|
|
}
|