Add send completed when reading finishes

This commit is contained in:
2026-05-07 13:41:55 +02:00
parent e8e4e3636c
commit a0585764cf
5 changed files with 38 additions and 15 deletions
+17 -12
View File
@@ -67,15 +67,26 @@ pub fn exec_pipe(
let send_stdout = send_process.stdout.take().unwrap();
let mut receive_stdin = receive_process.stdin.take().unwrap();
let mut reader: Box<dyn Read> = Box::new(send_stdout);
for filter in filters {
reader = filter.filter(reader);
{
let mut reader: Box<dyn Read> = Box::new(send_stdout);
for filter in filters {
reader = filter.filter(reader);
}
std::io::copy(&mut reader, &mut receive_stdin).map_err(|e| e.to_string())?;
}
std::io::copy(&mut reader, &mut receive_stdin).map_err(|e| e.to_string())?;
let receive_status = receive_process.wait().map_err(|e| e.to_string())?;
// The send process will typically finish first. If it failed, terminate the
// receiver.
let send_status = send_process.wait().map_err(|e| e.to_string())?;
if !send_status.success() {
receive_process.kill().ok();
return Err(format!(
"Send command {:?} failed with status {}",
source, send_status
));
}
let receive_status = receive_process.wait().map_err(|e| e.to_string())?;
if !receive_status.success() {
send_process.kill().ok();
return Err(format!(
@@ -83,11 +94,5 @@ pub fn exec_pipe(
dest, receive_status
));
}
if !send_status.success() {
return Err(format!(
"Send command {:?} failed with status {}",
source, send_status
));
}
Ok(())
}