Skip to content

Commit 1ece036

Browse files
authored
Merge pull request microsoft#720 from microsoft/tyriar/catch_winpty_deconstructor
Catch possible exceptions in ~Agent
2 parents 796e11e + 7e431b9 commit 1ece036

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

deps/winpty/src/agent/Agent.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,18 @@ Agent::Agent(LPCWSTR controlPipeName,
223223

224224
Agent::~Agent()
225225
{
226-
trace("Agent::~Agent entered");
227-
agentShutdown();
228-
if (m_childProcess != NULL) {
229-
CloseHandle(m_childProcess);
226+
trace("Agent::~Aent entered");
227+
try {
228+
agentShutdown();
229+
if (m_childProcess != NULL) {
230+
CloseHandle(m_childProcess);
231+
}
232+
} catch (const std::exception &e) {
233+
// Log the exception or handle it as needed
234+
trace("Exception in Agent::~Agent: %s", e.what());
235+
} catch (...) {
236+
// Catch any other types of exceptions
237+
trace("Unknown exception in Agent::~Agent");
230238
}
231239
}
232240

0 commit comments

Comments
 (0)