Repository navigation
Conversation
Merging this PR will improve performance by 3.71%1 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
|
GNU testsuite comparison: |
| return; | ||
| }; | ||
| show_error!("{message}"); | ||
| std::process::exit(code); |
There was a problem hiding this comment.
please don't use std::process::exit, could finish() return a UResult with USimpleError::new(code, message) and let it propagate?
There was a problem hiding this comment.
finish() now returns a UResult with USimpleError::new(code, message), and the writers and line_bytes propagate it.
| let _stdin = self.shell_process.stdin.as_mut(); | ||
| } | ||
| let exit_status = self | ||
| self.finish(); |
There was a problem hiding this comment.
exiting the process from a Drop is risky, with -n r/3 the other filters are never waited for
There was a problem hiding this comment.
Drop now only waits for the command, without reporting. For -n, all filters are waited for at the end and the first failure is returned, which is what GNU does with r/N.
| (message, code) | ||
| } else if let Some(signal) = status.signal() { | ||
| let name = signal_name(signal); | ||
| if name == "PIPE" { |
There was a problem hiding this comment.
comparing the signal number with SIGPIPE would be simpler than matching the name, no?
There was a problem hiding this comment.
Yes, it compares with libc::SIGPIPE now.
| } | ||
| } | ||
|
|
||
| #[cfg(not(target_os = "fuchsia"))] |
There was a problem hiding this comment.
do we need the fuchsia variant? signal_name_by_value already falls back
There was a problem hiding this comment.
uucore::signals is only built on the OS list in uucore/src/lib/lib.rs, and fuchsia is not in it, so it would not compile there. env does the same with not(target_os = "fuchsia").
| #[case::bytes("-b2")] | ||
| #[case::line_bytes("-C2")] | ||
| #[cfg(unix)] | ||
| fn test_filter_exit_status_stops_split(#[case] mode: &str) { |
There was a problem hiding this comment.
could you please add a case with -n r/2 too?
There was a problem hiding this comment.
Added test_filter_exit_status_round_robin with -n r/2, where all filters fail or only the second one does.
|
thanks for tackling this! |
|
No more |
|
thanks for picking this up! |
|
The red Tests job is OpenBSD: all the split filter tests pass there, including the signal ones; it fails later in the uucore doctest with missing rlibs (E0463), like other PRs. Will squash once it is otherwise ready. |
| fn test_filter_exit_status_stops_split(#[case] mode: &str) { | ||
| let (at, mut ucmd) = at_and_ucmd!(); | ||
| at.write("in", "a\nb\nc\n"); | ||
| let filter = "cat > /dev/null; echo $FILE >> calls; exit 5"; |
There was a problem hiding this comment.
could you please add a case where the filter doesn't read its input, like exit 5 alone? also with -n 2
There was a problem hiding this comment.
Added test_filter_exit_status_without_reading_input with exit 5 alone for -l, -b, -C and -n 2. The -n 2 case failed with split: Broken pipe, because that path wrote to the filter without ignoring the closed pipe, so I fixed it too.
|
Binary size comparison: |
9db74ea to
867c177
Compare
|
Squashed into one commit, no code change. |
0f951b4 to
0b23d4b
Compare
…failure Wait for each filter before opening the next output file, report 'with FILE=..., exit N from command: CMD' (or 'signal NAME') and exit with the command's status, or 128+N for a signal. A filter killed by SIGPIPE is not treated as an error.
0b23d4b to
5ae537b
Compare
# Conflicts: # src/uu/split/Cargo.toml
When a
--filtercommand failed, split printed "Shell process returned N", ran the filter for the remaining chunks anyway and exited with 1.Now, like GNU, split waits for each filter before opening the next output file, reports
with FILE=..., exit N from command: CMD(orsignal NAME) and exits right away with the command's status, or 128+N for a signal. A filter killed by SIGPIPE is not treated as an error.Closes #16491