Fix stderr event loss due to missing WaitForExit in DisposeProcess (#1280)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
parent
3caac28a76
commit
1dd06e73dc
1 changed files with 12 additions and 0 deletions
|
|
@ -227,6 +227,18 @@ public sealed partial class StdioClientTransport : IClientTransport
|
||||||
// and Node.js does not kill its children when it exits properly.
|
// and Node.js does not kill its children when it exits properly.
|
||||||
process.KillTree(shutdownTimeout);
|
process.KillTree(shutdownTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure all redirected stderr/stdout events have been dispatched
|
||||||
|
// before disposing. Only the no-arg WaitForExit() guarantees this;
|
||||||
|
// WaitForExit(int) (as used by KillTree) does not.
|
||||||
|
// This should not hang: either the process already exited on its own
|
||||||
|
// (no child processes holding handles), or KillTree killed the entire
|
||||||
|
// process tree. If it does take too long, the test infrastructure's
|
||||||
|
// own timeout will catch it.
|
||||||
|
if (!processRunning && HasExited(process))
|
||||||
|
{
|
||||||
|
process.WaitForExit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue