-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce stdin/stdout deadlocks #42
Comments
It's not hard to create a testcase that hits this, it's just probably unlikely to happen in common scenarios because pipe buffers are reasonably large (65k by default on Linux, >100k with large writes on macOS). Here's a testcase that deadlocks on my mac (just |
I just ran into this writing a test for a project I'm on. Once I found this issue, the workaround was simple (use a smaller test data), but unexpected to follow the example and get an obscure "Broken Pipe" error. |
@luser , I was looking at adopting your solution from sccache but something looks like a bug to me stdin.and_then(|t| t.join().unwrap().ok());
let stdout = child.take_stdout().map(read);
let stderr = child.take_stderr().map(read); sccache block on the stdin thread before spawning the stdout/stderr threads. Shouldn't those lines be swapped? let stdout = child.take_stdout().map(read);
let stderr = child.take_stderr().map(read);
stdin.and_then(|t| t.join().unwrap().ok()); |
I suspect you're right, good catch. The ordering of joining the stdin thread before calling |
From @luser on #28
So far, we haven't run into this but
The text was updated successfully, but these errors were encountered: