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,24 +84,24 @@ int opal_few(char *argv[], int *status)
#else #else
/* Welcome to windows land. This is apparently a simple fork() exec()
procedure and hence should not be too difficult to implement */
HANDLE new_process;
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
DWORD process_stat; DWORD process_stat;
char* command = argv[0];
/* it does seem as if the environment is getting propogated, so I char* exec_command;
will follow the same procedure in my code */
/* ANJU: Have to implement signal handling */
ZeroMemory (&si, sizeof(si)); ZeroMemory (&si, sizeof(si));
ZeroMemory (&pi, sizeof(pi)); ZeroMemory (&pi, sizeof(pi));
_flushall(); /* Push all output */
GetStartupInfo (&si); GetStartupInfo (&si);
argv[0] = opal_basename( command );
exec_command = opal_argv_join( argv, ' ' );
free( argv[0] );
argv[0] = command;
if (!CreateProcess (argv[0], if (!CreateProcess (argv[0],
argv, (LPSTR)exec_command,
NULL, NULL,
NULL, NULL,
TRUE, TRUE,
@ -108,15 +110,18 @@ int opal_few(char *argv[], int *status)
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();
return OPAL_ERROR;
}
*status = (int)process_stat;
SetLastError(process_stat);
return OPAL_SUCCESS; return OPAL_SUCCESS;
#endif #endif
} }