Commit 2359ab4
committed
Fix propagation of errors in
The error return pipe, `errpipe_write`, was not included in the "FDs to
keep" that were passed to `_posixsubprocess.fork_exec`. This resulted in
the pipe being closed in `_posixsubprocess.child_exec`, which in turn
meant errors from `os.execv`/`os.execve` could not be written to it,
preventing propagation.
We saw this manifest when our env vars became too large. `strace`
showed:
```
[pid 114] execve("/default-pegasus-venv/bin/python", ["/default-pegasus-venv/bin/python", "-B", "-c", "from multiprocessing.resource_tr"...], 0x62a996e37620 /* 311 vars */) = -1 E2BIG (Argument list too long)
[pid 114] write(31, "OSError:", 8) = -1 EBADF (Bad file descriptor)
[pid 114] write(31, "7", 1) = -1 EBADF (Bad file descriptor)
[pid 114] write(31, ":", 1) = -1 EBADF (Bad file descriptor)
[pid 114] write(31, "", 0) = -1 EBADF (Bad file descriptor)
```
This change fixes this, matching the behaviour in
`subprocess.Popen._execute_child`:
https://github.com/python/cpython/blob/138ed6db9f89171983dc32af4e7ad2e73d46a940/Lib/subprocess.py#L1897-L1901multiprocessing.util.spawnv_passfds
1 parent 83387e0 commit 2359ab4
2 files changed
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | | - | |
517 | 516 | | |
| 517 | + | |
| 518 | + | |
518 | 519 | | |
519 | 520 | | |
520 | 521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
982 | 983 | | |
983 | 984 | | |
984 | 985 | | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
985 | 1008 | | |
986 | 1009 | | |
987 | 1010 | | |
| |||
0 commit comments