Commit f9c5d43
fix: dup file descriptors in stdio_server to avoid closing real stdin/stdout
TextIOWrapper(sys.stdin.buffer) shares the underlying fd with sys.stdin.
When the wrapper is closed (or garbage-collected) after the server exits,
it also closes sys.stdin.buffer, making any subsequent stdio operation
raise `ValueError: I/O operation on closed file`.
Use `os.dup()` to duplicate the fd before wrapping, so closing the
wrapper only closes the duplicate while leaving the original process
handles intact.
Fixes #1933
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 62575ed commit f9c5d43
1 file changed
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| |||
0 commit comments