in src/agent/Agent.cc [514:538]
void Agent::autoClosePipesForShutdown()
{
if (m_closingOutputPipes) {
// We don't want to close a pipe before it's connected! If we do, the
// libwinpty client may try to connect to a non-existent pipe. This
// case is important for short-lived programs.
if (m_conoutPipe->isConnected() &&
m_conoutPipe->bytesToSend() == 0) {
trace("Closing CONOUT pipe (auto-shutdown)");
m_conoutPipe->closePipe();
}
if (m_conerrPipe != nullptr &&
m_conerrPipe->isConnected() &&
m_conerrPipe->bytesToSend() == 0) {
trace("Closing CONERR pipe (auto-shutdown)");
m_conerrPipe->closePipe();
}
if (m_exitAfterShutdown &&
m_conoutPipe->isClosed() &&
(m_conerrPipe == nullptr || m_conerrPipe->isClosed())) {
trace("Agent exiting (exit-after-shutdown)");
shutdown();
}
}
}