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;
ZeroMemory (&si, sizeof(si));
/* it does seem as if the environment is getting propogated, so I ZeroMemory (&pi, sizeof(pi));
will follow the same procedure in my code */
_flushall(); /* Push all output */
/* ANJU: Have to implement signal handling */
GetStartupInfo (&si);
ZeroMemory (&si, sizeof(si)); argv[0] = opal_basename( command );
ZeroMemory (&pi, sizeof(pi)); exec_command = opal_argv_join( argv, ' ' );
free( argv[0] );
GetStartupInfo (&si); argv[0] = command;
if (!CreateProcess (argv[0], if (!CreateProcess (argv[0],
argv, (LPSTR)exec_command,
NULL, NULL,
NULL, NULL,
TRUE, TRUE,
0, 0,
NULL, NULL,
NULL, NULL,
&si, &si,
&pi)){ &pi)){
/* actual error can be got by simply calling GetLastError() */ *status = (int)GetLastError();
return OPAL_ERROR; return OPAL_ERROR;
} }
/* wait for child to die */ /* wait for child to die */
WaitForSingleObject(pi.hProcess, INFINITE); WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &process_stat); if( 0 == GetExitCodeProcess(pi.hProcess, &process_stat) ) {
*status = (int)GetLastError();
SetLastError(process_stat); return OPAL_ERROR;
return OPAL_SUCCESS; }
*status = (int)process_stat;
return OPAL_SUCCESS;
#endif #endif
} }