Repository navigation
cksum, hashsum: error when stdin was closed at startup - #15267
Franklin-Qi wants to merge 1 commit into
Conversation
|
Please remove hashsum from title. We no longer have it. |
|
|
||
| /// Closed stdin must error with EBADF (GNU), not hash /dev/null as empty (#10153). | ||
| #[test] | ||
| #[cfg(unix)] |
There was a problem hiding this comment.
| #[cfg(unix)] | |
| #[cfg(unix)] | |
| #[cfg(not(wasi_runner))] |
or this would fail (host of test binary is still Linux...).
| .stdout_is_fixture("crc_stdin.expected"); | ||
| } | ||
|
|
||
| /// Closed stdin must error with EBADF (GNU), not hash /dev/null as empty (#10153). |
There was a problem hiding this comment.
| /// Closed stdin must error with EBADF (GNU), not hash /dev/null as empty (#10153). |
or remove issue hash at least for.
| if filename == "-" { | ||
| // Rust reopens a closed stdin as /dev/null before main; detect the | ||
| // original closed state captured at process start (#10153 / #2873). | ||
| #[cfg(unix)] |
There was a problem hiding this comment.
stdin_was_closed() already returns false on non-unix, is the cfg needed?
| // Rust reopens a closed stdin as /dev/null before main; detect the | ||
| // original closed state captured at process start (#10153 / #2873). | ||
| #[cfg(unix)] | ||
| if crate::signals::stdin_was_closed() { |
There was a problem hiding this comment.
what about cksum -c - with a closed stdin? it reads stdin in validate.rs
| let ebadf = | ||
| || io::Error::from_raw_os_error(rustix::io::Errno::BADF.raw_os_error()); | ||
| show!(ebadf().map_err_context(|| locale_aware_shell_escape(filename))); | ||
| show!(ebadf().map_err_context(|| "standard input".into())); |
There was a problem hiding this comment.
please use translate!() here
also, with cksum - - this will be printed twice, no?
| "expected failure on closed stdin, got {:?}", | ||
| output.status | ||
| ); | ||
| let stderr = String::from_utf8_lossy(&output.stderr); |
There was a problem hiding this comment.
could you please check the exact stderr instead of two contains?
| #[cfg(unix)] | ||
| if crate::signals::stdin_was_closed() { | ||
| let ebadf = | ||
| || io::Error::from_raw_os_error(rustix::io::Errno::BADF.raw_os_error()); |
There was a problem hiding this comment.
tac just uses io::Error::from_raw_os_error(libc::EBADF), could we do the same and drop the closure?
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | factor_five_38_bit_primes |
1.9 s | 2.2 s | -12.5% |
| ⚡ | Simulation | factor_three_39_bit_primes |
598.6 ms | 412 ms | +45.28% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Franklin-Qi:fix/10153-cksum-closed-stdin (f9b79bf) with main (175f6e1)2
Footnotes
-
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. ↩
-
No successful run was found on
main(b8657e8) during the generation of this report, so 175f6e1 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Rust remaps a closed stdin to /dev/null before main; use the startup capture so *sum rejects it with EBADF like GNU instead of hashing empty. Closes: uutils#10153
5b24db0 to
f9b79bf
Compare
|
hi, this one can't be merged as it is:
|
@sylvestre Thanks for your review. I will handle it today. |
Rust remaps a closed stdin to /dev/null before main; use the startup capture so *sum rejects it with EBADF like GNU instead of hashing empty.
Closes: #10153