Commit 8fb88a5
Implement cross-platform process termination using psutil
Replace platform-specific process termination code with a unified
psutil-based implementation that properly handles process trees on
both Windows and Unix systems.
Key changes:
- Add psutil as a required dependency for robust process management
- Replace custom Windows taskkill and Unix killpg implementations
with psutil's cross-platform process tree termination
- Fix FallbackProcess.wait() on Windows to use polling instead of
blocking, allowing anyio timeouts to work properly
- Add Windows-specific ResourceWarning filters with documentation
explaining why they occur (TerminateProcess() doesn't allow
cleanup handlers to run)
This ensures consistent behavior across platforms while properly
handling the fundamental differences in process termination:
- Unix: Uses signals (SIGTERM/SIGKILL) for graceful shutdown
- Windows: Uses TerminateProcess() which is immediate
All process termination tests now pass on both Windows and macOS.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 929a36a commit 8fb88a5
File tree
3 files changed
+18
-24
lines changed- src/mcp/client/stdio
- tests/client
3 files changed
+18
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
| 261 | + | |
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 286 | + | |
| 287 | + | |
290 | 288 | | |
291 | 289 | | |
292 | 290 | | |
293 | 291 | | |
294 | 292 | | |
295 | 293 | | |
296 | | - | |
| 294 | + | |
297 | 295 | | |
298 | 296 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 297 | + | |
| 298 | + | |
303 | 299 | | |
304 | 300 | | |
305 | 301 | | |
| |||
308 | 304 | | |
309 | 305 | | |
310 | 306 | | |
311 | | - | |
| 307 | + | |
312 | 308 | | |
313 | 309 | | |
314 | | - | |
| 310 | + | |
315 | 311 | | |
316 | 312 | | |
317 | 313 | | |
| |||
322 | 318 | | |
323 | 319 | | |
324 | 320 | | |
325 | | - | |
| 321 | + | |
326 | 322 | | |
327 | 323 | | |
328 | | - | |
| 324 | + | |
329 | 325 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
78 | | - | |
| 77 | + | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | | - | |
| 28 | + | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
371 | 370 | | |
372 | 371 | | |
373 | 372 | | |
374 | | - | |
| 373 | + | |
375 | 374 | | |
376 | 375 | | |
377 | 376 | | |
378 | 377 | | |
379 | 378 | | |
380 | 379 | | |
381 | 380 | | |
382 | | - | |
| 381 | + | |
383 | 382 | | |
384 | 383 | | |
385 | 384 | | |
| |||
0 commit comments