mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
Merge pull request #3275 from jfinkels/split-handle-broken-pipe
split: catch and handle broken pipe errors
This commit is contained in:
commit
f4146da604
1 changed files with 11 additions and 3 deletions
|
@ -1007,8 +1007,9 @@ where
|
||||||
writers.push(writer);
|
writers.push(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This block evaluates to an object of type `std::io::Result<()>`.
|
// Capture the result of the `std::io::copy()` calls to check for
|
||||||
{
|
// `BrokenPipe`.
|
||||||
|
let result: std::io::Result<()> = {
|
||||||
// Write `chunk_size` bytes from the reader into each writer
|
// Write `chunk_size` bytes from the reader into each writer
|
||||||
// except the last.
|
// except the last.
|
||||||
//
|
//
|
||||||
|
@ -1025,8 +1026,12 @@ where
|
||||||
io::copy(&mut reader.by_ref().take(last_chunk_size), &mut writers[i])?;
|
io::copy(&mut reader.by_ref().take(last_chunk_size), &mut writers[i])?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
};
|
||||||
|
match result {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(e) if e.kind() == ErrorKind::BrokenPipe => Ok(()),
|
||||||
|
Err(e) => Err(uio_error!(e, "input/output error")),
|
||||||
}
|
}
|
||||||
.map_err_context(|| "I/O error".to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Split a file into a specific number of chunks by line.
|
/// Split a file into a specific number of chunks by line.
|
||||||
|
@ -1204,6 +1209,7 @@ fn split(settings: &Settings) -> UResult<()> {
|
||||||
// indicate that. A special error message needs to be
|
// indicate that. A special error message needs to be
|
||||||
// printed in that case.
|
// printed in that case.
|
||||||
ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")),
|
ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")),
|
||||||
|
ErrorKind::BrokenPipe => Ok(()),
|
||||||
_ => Err(uio_error!(e, "input/output error")),
|
_ => Err(uio_error!(e, "input/output error")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1223,6 +1229,7 @@ fn split(settings: &Settings) -> UResult<()> {
|
||||||
// indicate that. A special error message needs to be
|
// indicate that. A special error message needs to be
|
||||||
// printed in that case.
|
// printed in that case.
|
||||||
ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")),
|
ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")),
|
||||||
|
ErrorKind::BrokenPipe => Ok(()),
|
||||||
_ => Err(uio_error!(e, "input/output error")),
|
_ => Err(uio_error!(e, "input/output error")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1242,6 +1249,7 @@ fn split(settings: &Settings) -> UResult<()> {
|
||||||
// indicate that. A special error message needs to be
|
// indicate that. A special error message needs to be
|
||||||
// printed in that case.
|
// printed in that case.
|
||||||
ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")),
|
ErrorKind::Other => Err(USimpleError::new(1, "output file suffixes exhausted")),
|
||||||
|
ErrorKind::BrokenPipe => Ok(()),
|
||||||
_ => Err(uio_error!(e, "input/output error")),
|
_ => Err(uio_error!(e, "input/output error")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue