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 <windows.h>
|
|
|
|
#include <mlvalues.h>
|
|
|
|
#include "unixsupport.h"
|
|
|
|
|
1996-09-17 07:43:05 -07:00
|
|
|
/* From the Caml runtime */
|
|
|
|
extern char * searchpath(char * name);
|
|
|
|
|
1997-09-03 07:38:02 -07:00
|
|
|
value win_create_process_native(value cmd, value cmdline, value env,
|
|
|
|
value fd1, value fd2, value fd3)
|
1996-09-04 07:17:43 -07:00
|
|
|
{
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFO si;
|
1996-09-17 07:43:05 -07:00
|
|
|
char * exefile, * envp;
|
1996-09-04 07:17:43 -07:00
|
|
|
|
1996-09-17 07:43:05 -07:00
|
|
|
exefile = searchpath(String_val(cmd));
|
|
|
|
if (exefile == NULL) exefile = String_val(cmd);
|
1996-09-04 07:17:43 -07:00
|
|
|
if (env != Val_int(0)) {
|
|
|
|
envp = String_val(Field(env, 0));
|
|
|
|
} else {
|
|
|
|
envp = NULL;
|
|
|
|
}
|
|
|
|
GetStartupInfo(&si);
|
|
|
|
si.dwFlags |= STARTF_USESTDHANDLES;
|
1997-09-03 07:38:02 -07:00
|
|
|
si.hStdInput = Handle_val(fd1);
|
|
|
|
si.hStdOutput = Handle_val(fd2);
|
|
|
|
si.hStdError = Handle_val(fd3);
|
1996-09-17 07:43:05 -07:00
|
|
|
if (! CreateProcess(exefile, String_val(cmdline), NULL, NULL,
|
1996-09-04 07:17:43 -07:00
|
|
|
TRUE, 0, envp, NULL, &si, &pi)) {
|
|
|
|
_dosmaperr(GetLastError());
|
1997-09-02 09:01:39 -07:00
|
|
|
uerror("create_process", cmd);
|
1996-09-04 07:17:43 -07:00
|
|
|
}
|
|
|
|
return Val_int(pi.hProcess);
|
|
|
|
}
|
|
|
|
|
1997-09-03 07:38:02 -07:00
|
|
|
value win_create_process(value * argv, int argn) /* ML */
|
1996-09-04 07:17:43 -07:00
|
|
|
{
|
|
|
|
return win_create_process_native(argv[0], argv[1], argv[2],
|
|
|
|
argv[3], argv[4], argv[5]);
|
|
|
|
}
|