Repository navigation
fix(executor): close orphaned stdio fd on persistent fd close; retire dead coproc at pipe read (Refs #3633) - #3634
Conversation
… dead coproc at pipe read (Refs #3633) Two coupled coproc retirement leaks: 1. close_persistent_fd dropped the fd-table endpoint but left the process descriptor at the redirector number open when the endpoint rode a transport handle at a different OS slot — a respawned coproc child's `exec >&-` freed the __RUBASH_FD_* dup while its real fd1 stayed open as a c2p writer, so the parent's read blocked until the child exited. GNU redir.c r_close_this closes the redirector descriptor itself; close_orphaned_process_fd now does the same for stdio slots (<3, where spawn wires the OS fd to the stream the endpoint describes), only when no other live endpoint references that descriptor. Numbered slots stay virtual — an open OS fd there is runtime-owned. 2. read_input_for_command never opened GNU's reap window for the coproc retire step: read.def:482 input_is_pipe classifies a pipe source, whose blocking waitchld window is where the dead coproc's status lands and cleanup disposes it (jobs.c:4173 coproc_pidchk -> execute_cmd.c:2225 coproc_reap). Mark the foreground wait so the next command-boundary refresh runs flush_pending_coproc_retirements; a regular-file read marks nothing. Pins: tests/issue3633 — the coproc.tests xcase shape (${COPROC[@]} empties after a pipe read on a dead coproc) and the issue2892 timing half (exec >&- child + read gets instant EOF, COPROC stays bound); both red on master, green with the pair. Verified the issue2892 pin and the fd/exec/coproc regression batch stay green. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:
续作记录:本轮未动代码(按分工,FAIL 只发报告)。 |
|
【WIN-AGENT-AUDIT】PR #3634 第2轮 — REWORK 完成,建议:PASS(待 CI 复核) 续作记录(2 commits,均未 force-push,push 前已 fetch 复核远端 head):
F 点逐条回应:
腿(本轮增量;产品面零改动):
未跑/VOID 的腿:无。 |
|
【WIN-AGENT-AUDIT】 本轮续作(接第2轮 REWORK 之后的 merge 收尾):
腿(head 709161b):
F 点:无新增。 |
Summary
Fixes the run-coproc residual (Refs #2666): two coupled leaks in coproc retirement.
exec >&-inside a coproc child left the real descriptor open: the respawned child fd1 endpoint rides a transport handle at a different OS slot, so dropping it freed the dup while real fd1 stayed open as an orphaned c2p writer — the parent read blocked until the child exited instead of meeting instant EOF.close_orphaned_process_fdnow closes the OS descriptor left at the redirector number for stdio slots, only when no other live endpoint references it (GNUredir.c r_close_this). Numbered slots stay virtual.readon a pipe never ran the retire step: GNUread.def:482input_is_pipeopens the reap window where a dead coproc status lands and cleanup disposes it (jobs.c:4173 coproc_pidchk->execute_cmd.c:2225 coproc_reap). The read now marks the foreground wait so the next command-boundary refresh runsflush_pending_coproc_retirements; a regular-file read marks nothing.Tests
New pins
tests/issue3633_coproc_eof_regressions.rs(both red on master, green here): the coproc.testsxcaseshape and theexec >&-child + live-coproc EOF timing. issue2892 pin stays green; fd/exec/coproc pin batch regression-clean (one pre-existing env failureissue2212_03also red on master); coproc.tests stdout+stderr byte-identical to vendored GNU 5.3.20.