Skip to content

yes: catch EBADF with >&- - #16299

Open
oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:read-only-stdout
Open

oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:read-only-stdout

Conversation

@oech3

@oech3 oech3 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Deprecate stdout_was_closed and re-open closed stdout as read-only. Then RawWriter raises EBADF automatically.
(We need to fix read-only stdout case too someday anyway)
Closes #11090 Closes #12160

@oech3
oech3 force-pushed the read-only-stdout branch 5 times, most recently from 37f7004 to 4a47c1a Compare November 9, 2026 05:11
@oech3

oech3 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

I'll drop other std*_was_closed later. But it needs large diff.

@oech3
oech3 force-pushed the read-only-stdout branch 6 times, most recently from c9ca672 to 6e7b06f Compare November 9, 2026 08:21
@oech3

oech3 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

@anastygnome We can ask std to open pipe reader when stdout was closed.

@codspeed

codspeed Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 4.31%

2 warnings, 1 note

⚠️ 119 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
✅ 412 untouched benchmarks
⏩ 70 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation df_deep_directory 930.1 µs 891.7 µs +4.31%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing oech3:read-only-stdout (8d1bc3e) with main (2775292)

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment thread src/uucore/src/lib/features/signals.rs Resolved
Comment thread src/uucore/src/lib/features/signals.rs Resolved
Comment thread src/uucore/src/lib/features/signals.rs Resolved
Comment thread src/uucore/src/lib/features/signals.rs Resolved
Comment thread src/uu/yes/src/platform/portable.rs Resolved
@anastygnome

anastygnome commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

@anastygnome We can ask std to open pipe reader when stdout was closed.

Oh you mean in the responsive PR, yes, we have such code in the std-detection code, called before the stdlib init right?.
By the way, Such code needs a refactor to call pollfd, you can go from 3 syscalls to 1

Comment thread src/uucore/src/lib/features/signals.rs Resolved
@oech3
oech3 force-pushed the read-only-stdout branch 4 times, most recently from 581d8f3 to 632c22e Compare November 9, 2026 11:03
@oech3

oech3 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

By the way, pipe pair is pain to maintain. Can we fail to open / instead under some specific situation?

@oech3
oech3 force-pushed the read-only-stdout branch 7 times, most recently from 10a320b to 33ec713 Compare November 9, 2026 16:41
@oech3
oech3 requested a review from sylvestre November 9, 2026 17:42
Comment thread src/uucore/src/lib/features/signals.rs Resolved
Comment thread src/uucore/src/lib/features/signals.rs Resolved
Comment thread src/uucore/src/lib/features/signals.rs Resolved
@oech3
oech3 force-pushed the read-only-stdout branch 2 times, most recently from 9ee40bb to dfaf25d Compare November 9, 2026 21:11
@oech3
oech3 force-pushed the read-only-stdout branch 2 times, most recently from b419996 to ad03b3b Compare November 10, 2026 09:41
@oech3
oech3 requested a review from sylvestre November 10, 2026 14:54
@oech3

oech3 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Is this OK to merge?

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)

Comment thread src/uucore/src/lib/features/signals.rs Resolved
@oech3
oech3 force-pushed the read-only-stdout branch 2 times, most recently from 0e31830 to 72e476c Compare November 17, 2026 06:30
@oech3

oech3 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@anastygnome rust-lang/rust#47271 (comment)

We can drop std*_was_closed() in the future at least for.

@oech3

oech3 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Do we really need to handle stderr at many utils? GNU does not report write error for stderr at most cases.
stderr_was_closed is used only on dd currently, but I don't know why it is used.

@oech3

oech3 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Oh OK. I unserstood. But dd status=progress 2>&- should not catch EBADF before typing something.
This PR should help fixing it.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.52 MB (+136 KB, +0.09%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

@oech3

oech3 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Rust std (main branch) started catching EBADF: rust-lang/rust#166117 .

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

all: closed std{out,err} causes SIGABRT if /dev is masked yes >&- does not stop

3 participants