-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Race condition in Pipe.Exec #193
Comments
Good spotting, @nclv! It doesn't really make a lot of sense to set the pipe's stdout or stderr after you've already started some command—you may or may not lose some of the output, depending on timing. The more reliable way to do this would be to set the preferred outputs first: script.NewPipe().WithStdout(stdOut).WithStderr(stdErr).Exec(cmdLine).Stdout() A data race still exists, of course: this merely adjusts the odds in your favour. The pipe already has a mutex, so we could use this to protect these fields. I'll have a look. |
@bitfield does this still need to be worked on? i'd like to contribute if its up for grabs |
Yes, you could start by writing a test that proves the data race, if you like. |
@bitfield the PR is ready for another review whenever you get a chance to have a look! |
There seems to be a data race with stdErr when executing the following piece of code in parallel (test with errgroup).
The text was updated successfully, but these errors were encountered: