1
1

That's the way we synchronously create a process on Windows.

This commit was SVN r11326.
Этот коммит содержится в:
George Bosilca 2006-08-22 18:02:10 +00:00
родитель ee5d0828e6
Коммит 0a2563037d

Просмотреть файл

@ -30,6 +30,8 @@
#endif #endif
#include "opal/util/few.h" #include "opal/util/few.h"
#include "opal/util/basename.h"
#include "opal/util/argv.h"
#include "opal/constants.h" #include "opal/constants.h"
int opal_few(char *argv[], int *status) int opal_few(char *argv[], int *status)
@ -82,41 +84,44 @@ int opal_few(char *argv[], int *status)
#else #else
/* Welcome to windows land. This is apparently a simple fork() exec() STARTUPINFO si;
procedure and hence should not be too difficult to implement */ PROCESS_INFORMATION pi;
HANDLE new_process; DWORD process_stat;
STARTUPINFO si; char* command = argv[0];
PROCESS_INFORMATION pi; char* exec_command;
DWORD process_stat;
/* it does seem as if the environment is getting propogated, so I ZeroMemory (&si, sizeof(si));
will follow the same procedure in my code */ ZeroMemory (&pi, sizeof(pi));
/* ANJU: Have to implement signal handling */ _flushall(); /* Push all output */
ZeroMemory (&si, sizeof(si)); GetStartupInfo (&si);
ZeroMemory (&pi, sizeof(pi)); argv[0] = opal_basename( command );
exec_command = opal_argv_join( argv, ' ' );
free( argv[0] );
argv[0] = command;
if (!CreateProcess (argv[0],
(LPSTR)exec_command,
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi)){
*status = (int)GetLastError();
return OPAL_ERROR;
}
GetStartupInfo (&si); /* wait for child to die */
if (!CreateProcess (argv[0], WaitForSingleObject(pi.hProcess, INFINITE);
argv, if( 0 == GetExitCodeProcess(pi.hProcess, &process_stat) ) {
NULL, *status = (int)GetLastError();
NULL, return OPAL_ERROR;
TRUE, }
0, *status = (int)process_stat;
NULL,
NULL,
&si,
&pi)){
/* actual error can be got by simply calling GetLastError() */
return OPAL_ERROR;
}
/* wait for child to die */ return OPAL_SUCCESS;
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &process_stat);
SetLastError(process_stat);
return OPAL_SUCCESS;
#endif #endif
} }