shell: Add func FreeQueueEvent for correct uninitialize shell wrapper (#115)
* shell: Add func FreeQueueEvent for correct uninitialize shell wrapper * shell: Close all handles on exit
This commit is contained in:
parent
339b2c7727
commit
16b0175b8e
|
@ -841,6 +841,19 @@ QueueEvent(DWORD event, HWND hwnd, LONG idObject, LONG idChild)
|
||||||
LeaveCriticalSection(&criticalSection);
|
LeaveCriticalSection(&criticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreeQueueEvent()
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&criticalSection);
|
||||||
|
while (head) {
|
||||||
|
consoleEvent* current = head;
|
||||||
|
head = current->next;
|
||||||
|
free(current);
|
||||||
|
}
|
||||||
|
head = NULL;
|
||||||
|
tail = NULL;
|
||||||
|
LeaveCriticalSection(&criticalSection);
|
||||||
|
}
|
||||||
|
|
||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
ProcessPipes(LPVOID p)
|
ProcessPipes(LPVOID p)
|
||||||
{
|
{
|
||||||
|
@ -1044,16 +1057,29 @@ start_with_pty(wchar_t *command)
|
||||||
ProcessMessages(NULL);
|
ProcessMessages(NULL);
|
||||||
cleanup:
|
cleanup:
|
||||||
dwStatus = GetLastError();
|
dwStatus = GetLastError();
|
||||||
DeleteCriticalSection(&criticalSection);
|
|
||||||
if (child != INVALID_HANDLE_VALUE)
|
if (child != INVALID_HANDLE_VALUE)
|
||||||
TerminateProcess(child, 0);
|
TerminateProcess(child, 0);
|
||||||
if (monitor_thread != INVALID_HANDLE_VALUE)
|
if (monitor_thread != INVALID_HANDLE_VALUE) {
|
||||||
WaitForSingleObject(monitor_thread, INFINITE);
|
WaitForSingleObject(monitor_thread, INFINITE);
|
||||||
if (ux_thread != INVALID_HANDLE_VALUE)
|
CloseHandle(monitor_thread);
|
||||||
|
}
|
||||||
|
if (ux_thread != INVALID_HANDLE_VALUE) {
|
||||||
TerminateThread(ux_thread, S_OK);
|
TerminateThread(ux_thread, S_OK);
|
||||||
|
CloseHandle(ux_thread);
|
||||||
|
}
|
||||||
|
if (io_thread != INVALID_HANDLE_VALUE) {
|
||||||
|
TerminateThread(io_thread, 0);
|
||||||
|
CloseHandle(io_thread);
|
||||||
|
}
|
||||||
if (hEventHook)
|
if (hEventHook)
|
||||||
__UnhookWinEvent(hEventHook);
|
__UnhookWinEvent(hEventHook);
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
|
if (child != INVALID_HANDLE_VALUE) {
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
}
|
||||||
|
FreeQueueEvent();
|
||||||
|
DeleteCriticalSection(&criticalSection);
|
||||||
|
|
||||||
return child_exit_code;
|
return child_exit_code;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue