From cab8bd1f761e3be1ea377f4f33ef4e3fbf4c15ff Mon Sep 17 00:00:00 2001 From: Kirill Date: Sun, 17 Jan 2010 03:06:52 -0500 Subject: [PATCH] Monitor the parent process and close the shell on its exit If Console crashes for no apparent reason, all child shells keep running. Monitoring the parent process from ConsoleHook will close them if the parent accidentally disappears. --- ConsoleHook/ConsoleHandler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ConsoleHook/ConsoleHandler.cpp b/ConsoleHook/ConsoleHandler.cpp index 1c6a9c23..57141885 100644 --- a/ConsoleHook/ConsoleHandler.cpp +++ b/ConsoleHook/ConsoleHandler.cpp @@ -980,6 +980,7 @@ DWORD ConsoleHandler::MonitorThread() m_consoleMouseEvent.GetReqEvent(), m_newConsoleSize.GetReqEvent(), hStdOut.get(), + m_hParentProcess.get() }; DWORD dwWaitRes = 0; @@ -1102,6 +1103,11 @@ DWORD ConsoleHandler::MonitorThread() break; } + // close the console if the parent process died + case WAIT_OBJECT_0 + 7: + ::SendMessage(m_consoleParams->hwndConsoleWindow, WM_CLOSE, 0, 0); + break; + } }