Skip to content

Commit

Permalink
Merge pull request microsoft#720 from microsoft/tyriar/catch_winpty_d…
Browse files Browse the repository at this point in the history
…econstructor

Catch possible exceptions in ~Agent
  • Loading branch information
Tyriar authored Oct 3, 2024
2 parents 796e11e + 7e431b9 commit 1ece036
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions deps/winpty/src/agent/Agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,18 @@ Agent::Agent(LPCWSTR controlPipeName,

Agent::~Agent()
{
trace("Agent::~Agent entered");
agentShutdown();
if (m_childProcess != NULL) {
CloseHandle(m_childProcess);
trace("Agent::~Aent entered");
try {
agentShutdown();
if (m_childProcess != NULL) {
CloseHandle(m_childProcess);
}
} catch (const std::exception &e) {
// Log the exception or handle it as needed
trace("Exception in Agent::~Agent: %s", e.what());
} catch (...) {
// Catch any other types of exceptions
trace("Unknown exception in Agent::~Agent");
}
}

Expand Down

0 comments on commit 1ece036

Please sign in to comment.