Python per CreateProcess gestartet, Fenster schließt nicht
-
Hallo,
ich habe folgendes Problem:
Ich starte eine Python Datei über CreateProcess und die Python Datei wird auch korrekt ausgeführt.STARTUPINFO si; PROCESS_INFORMATION pi; CComBSTR szCmdline = (" "); szCmdline.Append(simulationbridge); szCmdline.Append(" "); szCmdline.Append("simulation"); szCmdline.Append(" "); szCmdline.Append(databaseName); szCmdline.Append("@"); szCmdline.Append(serverName); szCmdline.Append(" "); szCmdline.Append(LoginName); szCmdline.Append(" "); szCmdline.Append(Password); szCmdline.Append(" "); szCmdline.Append(activeSession); ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); //si.dwFlags = STARTF_USESHOWWINDOW; //si.wShowWindow = SW_HIDE; ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess( pythonexe, // python interpreter szCmdline, // 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 ) { ::MessageBox(0,CComBSTR(GetLastError()),CComBSTR("CreateProcess failed"),MB_OK); return -1; } // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); TerminateThread(pi.hThread,NULL); CloseHandle( pi.hThread );Nachdem die Simulation ausgeführt wurde läuft mein weiterer C++ Code auch ab (also alles was hier nach CloseHandle( pi.hThread ) folgen würde), nur das Cmd Fenster bleibt weiter offen. Erst wenn ich in dem Fenster Ctrl+C drücke wird auch dieses geschlossen.
Anscheinend läuft der Python Interpreter im Hintergrund weiter...
Aber wieso läuft mein C++ Code dann nach WaitForSingleObject weiter und wieso "tötet" TerminateThread nicht das Fenster?
Es tut mir leid wenn es tatsächlich daran liegt das das Python Script den Interpreter nicht richtig beended, aber im Moment bin ich etwas verwirrt, da ich dann nicht erwartet hätte das es nach WaitForSingleObject weiter läuft...Danke schonmal und Grüsse
Christian