Skip to content

Commit

Permalink
tests/common/util: Fix uutils#3895 broken pipe error when using pipep…
Browse files Browse the repository at this point in the history
… input in UCommand
  • Loading branch information
Joining7943 authored and sylvestre committed Sep 10, 2022
1 parent e860eb8 commit 795ab1f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::env;
use std::ffi::CString;
use std::ffi::OsStr;
use std::fs::{self, hard_link, File, OpenOptions};
use std::io::{Read, Result, Write};
use std::io::{BufWriter, Read, Result, Write};
#[cfg(unix)]
use std::os::unix::fs::{symlink as symlink_dir, symlink as symlink_file};
#[cfg(windows)]
Expand Down Expand Up @@ -1105,13 +1105,14 @@ impl UCommand {
}

if let Some(ref input) = self.bytes_into_stdin {
let write_result = child
let child_stdin = child
.stdin
.take()
.unwrap_or_else(|| panic!("Could not take child process stdin"))
.write_all(input);
.unwrap_or_else(|| panic!("Could not take child process stdin"));
let mut writer = BufWriter::new(child_stdin);
let result = writer.write_all(input);
if !self.ignore_stdin_write_error {
if let Err(e) = write_result {
if let Err(e) = result {
panic!("failed to write to stdin of child: {}", e);
}
}
Expand Down

0 comments on commit 795ab1f

Please sign in to comment.