#include int main( VOID ) { STARTUPINFO si; PROCESS_INFORMATION pi; LPDWORD result; int i; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess( NULL, // No module name (use command line). "childWin.exe", // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. ) { return 1; } for (i=0; i<10;i++) { printf("parent %d\n",i); Sleep(1000); } //wait for child to exit WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, result); printf("child's exit code was: %i\n", *result); return 0; }