Repository navigation
Conversation
2dda7a0 to
486df67
Compare
Merging this PR will degrade performance by 16.88%2 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
GNU testsuite comparison: |
| // On non-macOS systems, use is_stdin_directory() which works correctly | ||
| #[cfg(not(target_os = "macos"))] | ||
| { | ||
| if uucore::fs::is_stdin_directory(&stdin()) { |
There was a problem hiding this comment.
Why can't we simply fix the uucore function?
There was a problem hiding this comment.
We clarified offline that "sr" means "sorry", and "@@" is a dizzy face smiley meaning overwhelmed / confused.
There was a problem hiding this comment.
@@ -> icon 😵 or 😵💫
There was a problem hiding this comment.
if I were an AI, i would write comments in an expert tone, akin to a research paper or technical doc :v
a875910 to
6fb203c
Compare
|
GNU testsuite comparison: |
6fb203c to
72737e7
Compare
|
GNU testsuite comparison: |
72737e7 to
98c7793
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
Can you please check the CI issue? |
bb9ced1 to
f54dcc6
Compare
|
GNU testsuite comparison: |
8be39c8 to
00a6bf7
Compare
| let num_bytes = filehandle.read(&mut self.buffer)?; | ||
| let num_bytes = match filehandle.read(&mut self.buffer) { | ||
| Ok(num_bytes) => num_bytes, | ||
| Err(error) if error.kind() == ErrorKind::WouldBlock => 0, |
There was a problem hiding this comment.
treating WouldBlock as EOF looks like a workaround for the O_NONBLOCK above, please drop both
| Err(mpsc::RecvTimeoutError::Timeout) => { | ||
| timeout_counter += 1; | ||
| #[cfg(unix)] | ||
| paths.extend(observer.files.fifo_keys()); |
There was a problem hiding this comment.
polling fifos on every timeout isn't related to #9292, please split that into another pr
| } | ||
|
|
||
| #[test] | ||
| fn test_input_resolve_does_not_panic_on_stdin() { |
There was a problem hiding this comment.
these tests don't assert anything (let _ = result).
please add a real test in tests/by-util/test_tail.rs with piped stdin instead
| use follow::Observer; | ||
| use memchr::{memchr_iter, memrchr_iter}; | ||
| use paths::{FileExtTail, HeaderPrinter, Input, InputKind}; | ||
| use same_file::Handle; |
There was a problem hiding this comment.
same-file was just removed from tail on main (#14208), please rebase and don't bring it back
| if settings.follow.is_some() | ||
| && metadata.is_some_and(|metadata| metadata.file_type().is_fifo()) | ||
| { | ||
| options.custom_flags(libc::O_NONBLOCK); |
There was a problem hiding this comment.
O_NONBLOCK is never cleared here, and main's --pid FIFO logic is gone. Why is this in a pseudo fix?
| file: &mut R, | ||
| limit: Option<u64>, | ||
| ) -> UResult<()> { | ||
| fn print_target_section<R>(file: &mut R, limit: Option<u64>) -> io::Result<()> |
There was a problem hiding this comment.
this reverts the splice zero-copy path from main, looks like a bad rebase.
please keep only the paths.rs change for #9292
| @@ -415,10 +383,6 @@ fn forwards_thru_file( | |||
| /// `num_delimiters` instance of `delimiter`. The `file` is left seek'd to the | |||
| /// position just after that delimiter. | |||
| fn backwards_thru_file(file: &mut File, num_delimiters: u64, delimiter: u8) { | |||
There was a problem hiding this comment.
why remove the num_delimiters == 0 early return?
00a6bf7 to
a93d9db
Compare
`tail` resolved `/dev/fd/0` whenever standard input was not a regular file. With pseudo (used by some build systems) that call answers with a path to a pipe that cannot be opened, so `tail -n 1 /dev/stdin` failed with "cannot open '/dev/stdin' for reading". Classify the fd first: only a redirected regular file or directory is canonicalized. The classification moves FIFO stdin onto the pipe branch, so `-f --pid=P` needs the `-` stdin key in the follow map: without it, `follow()` reports "no files remaining" and exits 1. That also fixes `tail -f --pid=P < pipe`, which already exited 1 on main while GNU exits 0. The update-alternatives pipeline from uutils#9292 already succeeds on current main (since 7d5cb58 reads stdin through fd 0); this change fixes the remaining `/dev/stdin` case and the follow-mode pair it requires. Refs uutils#9292
84bead9 to
da7e066
Compare
| { | ||
| PathBuf::from(text::FD0).canonicalize().ok() | ||
| // Pipes, FIFOs and other special files are left on the read path. | ||
| if let Ok(metadata) = std::fs::metadata(text::FD0) { |
There was a problem hiding this comment.
could we fstat stdin directly instead of going through the /dev/fd/0 path? that's the lookup pseudo dislikes
| /// | ||
| /// On main this exits 1 with "no files remaining": the pipe branch never inserts | ||
| /// the stdin key, yet `follow()` still runs because `--pid` is set. GNU ignores | ||
| /// `-f` for pipe stdin and exits 0 after reading EOF, printing the data. |
There was a problem hiding this comment.
"On main" will be wrong once this lands, and the 4 lines of WASI comment below could go too, the attribute is explicit
| fn test_pipe_stdin_with_pid() { | ||
| use std::process::{Command, Stdio}; | ||
|
|
||
| let ts = TestScenario::new(util_name!()); |
There was a problem hiding this comment.
the dead pid setup is the same in both tests, could be dedup into a small helper, no?
avoid canonicalizing pipe/FIFO stdin, which can resolve to an unusable path under
pseudoand break/dev/stdinpreserve the
-key in follow mode to handle stdin with--pidcorrectlyTests:
Added regression tests for pipe and FIFO stdin with --pid,
and checked the behavior against GNU coreutils 9.4.
Refs #9292