Repository navigation
fix(procsub,redir): separate BrokenPipe from EBADF and inherit runtime SIG_IGN across procsub respawn (Fixes #4255) - #4260
Conversation
|
Captain review — passes the gate, merge after rebase. Checked against GNU bash 5.3.20 source, line by line: subst.c:6426 ( CI: census 7 FAIL, all on the known rotator/stable list, 0 SIGABRT, goldens only the 2 standing snapshots. New pins 6/6 actually executed (sync-barrier repro so the unread-procsub-pipe case isn't schedule-dependent), and the fail-first direction is sound — the default-silent pin must print One ask before merging: the base ( Non-blocking suggestion: after merging, I'll re-run the #4255 minimal repro ( |
2f368a6 to
7148e03
Compare
|
Rebased onto current
Fresh CI is running now. |
|
Captain follow-up — the rebase landed clean and the new CI is exactly the known set (census 8 FAIL: issue2024 / issue2340 Please rebase once more onto current master (which now includes #4259) and confirm mergeable + fresh CI. If the census is still the same known names, I'll merge it immediately — nothing else is blocking. |
…e SIG_IGN across procsub respawn (Fixes #4255)
7148e03 to
1a64180
Compare
|
Rebased onto |
Summary
Stop misclassifying a readerless process-substitution pipe's
BrokenPipe/ WindowsERROR_NO_DATA (232)asBad file descriptor(EBADF), and propagate runtime-ignored signal dispositions (trap '' PIPE) across process-substitution respawns to match GNU Bash 5.3.20 (Fixes #4255).GNU C Specification
third_party/bash/subst.c:6362(process_substitute()),:6412(make_child()),:6426(restore_original_signals()).third_party/bash/trap.c:1433-1452(reset_or_restore_signal_handlers()): resets caught traps in the forked child while preservingSIG_IGNentries (visible totrap -pand re-trappable).third_party/bash/builtins/common.c:320-334(sh_chkwrite()): a write to a genuinely closed stdout (>&-) fails withEBADF(write error: Bad file descriptor); a write to a broken pipe with defaultSIGPIPEkills the producer silently (status 141), whereas undertrap '' PIPEit failsEPIPE(write error: Broken pipe).Root Cause & Changes
src/executor/redirection.rs:is_broken_pipe_output_error(ErrorKind::BrokenPipe/ WindowsERROR_NO_DATA (232)/ERROR_BROKEN_PIPE (109)) fromis_closed_output_error(ERROR_INVALID_HANDLE (6)on Windows /EBADFon Unix).is_closed_output_errormatchedBrokenPipe/232, causing buffered builtins likeprintfinside an unread<(printf 'hi\n')on Windows to emitprintf: write error: Bad file descriptor.SIGPIPEdisposition in a respawned child (respawned_child_broken_pipe_dies()), returnErr(ExecuteError::BrokenPipe)so the child exits silently like UnixSIGPIPE(141); undertrap '' PIPE, fall through tosh_chkwrite(write error: Broken pipe).BrokenPipeerror for a closed coprocess input withbad_file_descriptor_io_error().src/builtins/trap.rs+src/executor/compound_exec/transport.rs+src/executor/init.rs+src/executor/shell_options.rs+src/executor/ast_exec.rs:FORK_IGNORED_SIGNALS_TRANSPORT(__RUBASH_FORK_IGNORED_SIGNALS, stripped inFORK_TRANSPORT_KEYS) carrying non-hard-ignored runtimeSIG_IGNentries across respawn and installed viainstall_fork_inherited_ignore()ininit.rs.Executor::respawned_child_broken_pipe_dies(&self)soast_exec.rsandredirection.rsshare one SIGPIPE-vs-EPIPE verdict.tests/issues_4200_4299.rs+tests/issues_4200_4299/issue4255_procsub_broken_pipe_write_error.rs:<(printf 'hi\n')/<(echo hi)/<(pwd)silence under default SIGPIPE,printf: write error: Broken pipe(and noBad file descriptor) undertrap '' PIPE,trap -p PIPEvisibility & re-trapping across<(...), and genuinely closed stdout (>&-) still reportingBad file descriptor.What this PR deletes
ErrorKind::BrokenPipe/ WindowsERROR_NO_DATA (232)withBad file descriptorinsideis_closed_output_error(src/executor/redirection.rs).ErrorKind::BrokenPipeerror returned for closed coprocess input inOutputFdState(replaced with realEBADF/ERROR_INVALID_HANDLE).Verification
/usr/local/bin/bash):<(printf 'hi\n')/<(echo hi)/<(pwd): silent (rc=0).trap '' PIPE+ unread<(printf 'hi\n'):printf: write error: Broken pipe(neverBad file descriptor).trap '' PIPE; cat <(trap -p PIPE)->trap -- '' SIGPIPE; re-trapping inside<(...)succeeds (rc=0,trap -- 'echo inner' SIGPIPE).printf 'hi\n' >&-/echo hi >&-/pwd >&-:write error: Bad file descriptor(rc=1).RUSTFLAGS="-D warnings" cargo check --lib --locked: clean (0 warnings).cargo test --lib env_namespace_census_is_complete --locked: passed.cargo test --test issues_4200_4299 --locked: 8/8 passed.RUSTFLAGS="-D warnings" cargo check --lib --locked(after rebase onto8407b40ad): clean (0 warnings).cargo test --test issues_4200_4299 --locked: 8/8 passed.cargo test --test issues_0400_0599 issue510 --locked: 5/5 passed.cargo test --test issues_0600_0999 issue699 --locked: 7/7 passed.cargo test --test issues_3900_4199 issue4028 --locked: 5/5 passed.cargo test --lib env_namespace_census_is_complete --locked: passed.python scripts/check-rustfmt.py: ok (226 targets).python scripts/check-marker-literals.py: OK.python scripts/check-api-ledger.py: OK (298 symbols).Fixes #4255