Skip to content

Commit

Permalink
Monitor the parent process and close the shell on its exit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Kirill committed Jan 17, 2010
1 parent 250fea2 commit cab8bd1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ConsoleHook/ConsoleHandler.cpp
Expand Up @@ -980,6 +980,7 @@ DWORD ConsoleHandler::MonitorThread()
m_consoleMouseEvent.GetReqEvent(),
m_newConsoleSize.GetReqEvent(),
hStdOut.get(),
m_hParentProcess.get()
};

DWORD dwWaitRes = 0;
Expand Down Expand Up @@ -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;

}
}

Expand Down

0 comments on commit cab8bd1

Please sign in to comment.