Commit 59848b1
committed
fix: use os.dup to prevent closing real stdio after server exits
When using transport="stdio", the server wraps sys.stdin.buffer and
sys.stdout.buffer with TextIOWrapper. When these wrappers are closed,
they also close the underlying sys.stdin/sys.stdout, causing subsequent
stdio operations to fail with 'ValueError: I/O operation on closed file'.
This fix uses os.dup() to create duplicate file descriptors, ensuring
that closing our wrappers doesn't affect the original process streams.
Fixes #19331 parent 16969be commit 59848b1
1 file changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
44 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
0 commit comments