Conversation
|
GNU testsuite comparison: |
|
|
||
| for path in files { | ||
| if let Err(err) = cat_path(path, options, &mut state, out_info.as_ref()) { | ||
| if let CatError::Io(ref err_io) = err { |
There was a problem hiding this comment.
please add comments to explain what you are doing
| #[cfg(target_os = "linux")] | ||
| mod linux_only { | ||
| use uutests::util::{CmdResult, TestScenario, UCommand}; | ||
|
|
||
| use std::fmt::Write; | ||
| use std::fs::File; | ||
| use std::process::Stdio; | ||
| use uutests::new_ucmd; | ||
| use uutests::util_name; | ||
|
|
||
| fn make_broken_pipe() -> File { | ||
| use libc::c_int; | ||
| use std::os::unix::io::FromRawFd; | ||
|
|
||
| let mut fds: [c_int; 2] = [0, 0]; | ||
| assert!( | ||
| (unsafe { libc::pipe(std::ptr::from_mut::<c_int>(&mut fds[0])) } == 0), | ||
| "Failed to create pipe" | ||
| ); | ||
|
|
||
| // Drop the read end of the pipe | ||
| let _ = unsafe { File::from_raw_fd(fds[0]) }; | ||
|
|
||
| // Make the write end of the pipe into a Rust File | ||
| unsafe { File::from_raw_fd(fds[1]) } | ||
| } |
There was a problem hiding this comment.
@sylvestre I stole this from the tee test code:
coreutils/tests/by-util/test_tee.rs
Lines 163 to 298 in 402907e
Is that OK, or would you prefer we find some way of hosting these in a shareable location, if the latter, any advice on preferred approach would be appreciated.
At present, the `cat` command unexpectedly prints an error message when it receives a broken pipe error. As an example, there are many workflows that make use of `cat` and `head` together to process only part of the data. The `head` command will stop reading after a configured number of bytes or lines, subsequently exposing `cat` to a broken pipe condition. Said workflows may fail when they unexpectedly get error messages in their output. Suppress broken pipe errors. Signed-off-by: Frode Nordahl <fnordahl@ubuntu.com>
46e7b9e to
f2508fd
Compare
|
GNU testsuite comparison: |
|
The Android / Test builds (ubuntu-latest, 4, 4096, 28, google_apis_playstore, x check appears to have failed intermittently during initialization and might be unrelated to the change at hand? |
|
@fnordahl yes, it looks unrelated. Anyway, I restarted it. |
|
This was superseded by #8336 I believe sand is no longer needed |
|
Awesome, great that it was eventually fixed @julian-klode. Curious about the choice of messing with |
At present, the
catcommand unexpectedly prints an error message when it receives a broken pipe error.As an example, there are many workflows that make use of
catandheadtogether to process only part of the data. Theheadcommand will stop reading after a configured number of bytes or lines, subsequently exposingcatto a broken pipe condition.Said workflows may fail when they unexpectedly get error messages in their output.
Suppress broken pipe errors.