Skip to content

Commit d69e0d0

Browse files
committed
Write to stdin in a separate thread
Avoid deadlock when the child process writes to stdout and fills the buffer. See rust-lang/rust@ce2d95c
1 parent 2717f49 commit d69e0d0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ fn main() {
2525
.spawn()
2626
.expect("Failed to execute process");
2727

28-
let stdin = child.stdin.as_mut().expect("Failed to open stdin");
29-
stdin.write_all(dockerfile).unwrap();
28+
let mut stdin = child.stdin.take().expect("Failed to open stdin");
29+
std::thread::spawn(move || {
30+
stdin.write_all(dockerfile).unwrap();
31+
});
3032

3133
let status = child.wait().expect("failed to wait on child");
3234

0 commit comments

Comments
 (0)