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
#include "opal/util/few.h"
#include "opal/util/basename.h"
#include "opal/util/argv.h"
#include "opal/constants.h"
int opal_few(char *argv[], int *status)
@ -82,41 +84,44 @@ int opal_few(char *argv[], int *status)
#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;
PROCESS_INFORMATION pi;
DWORD process_stat;
/* it does seem as if the environment is getting propogated, so I
will follow the same procedure in my code */
/* ANJU: Have to implement signal handling */
ZeroMemory (&si, sizeof(si));
ZeroMemory (&pi, sizeof(pi));
GetStartupInfo (&si);
if (!CreateProcess (argv[0],
argv,
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi)){
/* actual error can be got by simply calling GetLastError() */
return OPAL_ERROR;
}
/* wait for child to die */
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &process_stat);
SetLastError(process_stat);
return OPAL_SUCCESS;
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD process_stat;
char* command = argv[0];
char* exec_command;
ZeroMemory (&si, sizeof(si));
ZeroMemory (&pi, sizeof(pi));
_flushall(); /* Push all output */
GetStartupInfo (&si);
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;
}
/* wait for child to die */
WaitForSingleObject(pi.hProcess, INFINITE);
if( 0 == GetExitCodeProcess(pi.hProcess, &process_stat) ) {
*status = (int)GetLastError();
return OPAL_ERROR;
}
*status = (int)process_stat;
return OPAL_SUCCESS;
#endif
}