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>
|
1997-09-04 06:45:56 -07:00
|
|
|
#include <memory.h>
|
1996-09-04 07:17:43 -07:00
|
|
|
#include <alloc.h>
|
|
|
|
#include "unixsupport.h"
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2009-05-20 04:52:42 -07:00
|
|
|
/* PR#4749: pick a size that matches that of I/O buffers */
|
|
|
|
#define SIZEBUF 4096
|
1996-09-04 07:17:43 -07:00
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLprim value unix_pipe(value unit)
|
1996-09-04 07:17:43 -07:00
|
|
|
{
|
1997-09-04 06:45:56 -07:00
|
|
|
SECURITY_ATTRIBUTES attr;
|
1997-09-03 07:38:02 -07:00
|
|
|
HANDLE readh, writeh;
|
|
|
|
value readfd = Val_unit, writefd = Val_unit, res;
|
|
|
|
|
1997-09-04 06:45:56 -07:00
|
|
|
attr.nLength = sizeof(attr);
|
|
|
|
attr.lpSecurityDescriptor = NULL;
|
|
|
|
attr.bInheritHandle = TRUE;
|
|
|
|
if (! CreatePipe(&readh, &writeh, &attr, SIZEBUF)) {
|
2001-08-28 07:47:48 -07:00
|
|
|
win32_maperr(GetLastError());
|
1997-09-03 07:38:02 -07:00
|
|
|
uerror("pipe", Nothing);
|
|
|
|
}
|
|
|
|
Begin_roots2(readfd, writefd)
|
|
|
|
readfd = win_alloc_handle(readh);
|
|
|
|
writefd = win_alloc_handle(writeh);
|
1998-10-26 11:19:32 -08:00
|
|
|
res = alloc_small(2, 0);
|
1997-09-03 07:38:02 -07:00
|
|
|
Field(res, 0) = readfd;
|
|
|
|
Field(res, 1) = writefd;
|
|
|
|
End_roots();
|
1996-09-04 07:17:43 -07:00
|
|
|
return res;
|
|
|
|
}
|