File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/ModelContextProtocol.Core/Client Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,18 @@ internal static void DisposeProcess(
227227 // and Node.js does not kill its children when it exits properly.
228228 process . KillTree ( shutdownTimeout ) ;
229229 }
230+
231+ // Ensure all redirected stderr/stdout events have been dispatched
232+ // before disposing. Only the no-arg WaitForExit() guarantees this;
233+ // WaitForExit(int) (as used by KillTree) does not.
234+ // This should not hang: either the process already exited on its own
235+ // (no child processes holding handles), or KillTree killed the entire
236+ // process tree. If it does take too long, the test infrastructure's
237+ // own timeout will catch it.
238+ if ( ! processRunning && HasExited ( process ) )
239+ {
240+ process . WaitForExit ( ) ;
241+ }
230242 }
231243 finally
232244 {
You can’t perform that action at this time.
0 commit comments