Tweak Window system-exec, wait for process to terminate
This commit is contained in:
parent
d09c049fee
commit
0b8d5d3dc5
|
@ -407,15 +407,21 @@ SystemExec::terminate ()
|
||||||
close_stdin();
|
close_stdin();
|
||||||
|
|
||||||
if (pid) {
|
if (pid) {
|
||||||
/* terminate */
|
/* close windows (if any) */
|
||||||
EnumWindows(my_terminateApp, (LPARAM)pid->dwProcessId);
|
EnumWindows (my_terminateApp, (LPARAM)pid->dwProcessId);
|
||||||
PostThreadMessage(pid->dwThreadId, WM_CLOSE, 0, 0);
|
|
||||||
|
if (PostThreadMessage (pid->dwThreadId, WM_CLOSE, 0, 0)) {
|
||||||
|
/* OK, wait for child to terminate cleanly */
|
||||||
|
WaitForSingleObject(pid->hProcess, 150 /*ms*/);
|
||||||
|
}
|
||||||
|
|
||||||
/* kill ! */
|
/* kill ! */
|
||||||
TerminateProcess(pid->hProcess, 0xf291);
|
TerminateProcess(pid->hProcess, 0);
|
||||||
|
wait ();
|
||||||
|
|
||||||
CloseHandle(pid->hThread);
|
|
||||||
CloseHandle(pid->hProcess);
|
CloseHandle(pid->hProcess);
|
||||||
|
CloseHandle(pid->hThread);
|
||||||
|
pid->hThread = pid->hProcess = 0;
|
||||||
destroy_pipe(stdinP);
|
destroy_pipe(stdinP);
|
||||||
destroy_pipe(stdoutP);
|
destroy_pipe(stdoutP);
|
||||||
destroy_pipe(stderrP);
|
destroy_pipe(stderrP);
|
||||||
|
|
Loading…
Reference in New Issue