-
Notifications
You must be signed in to change notification settings - Fork 18k
os/exec: Cmd can only be executed once, but that isn't documented #10305
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
Comments
Same approach is used for documenting concurrent access safety everywhere. Unless marked safe, it is implicitly not concurrent safe. |
@cznic I don't really understand your response. The API documented in os/exec doesn't talk about the fact that it's one use, and the cause of errors seem implementation-specific. Calling a function multiple times safely is the assumed behaviour of most APIs - I wouldn't expect documentation to clarify that it's safe to call fmt.Println multiple times. If it helps, try to imagine if you were implementing an alternative implementation of the os/exec module. Would it be clear to you (without looking at the code) whether or not Run should be reusable? |
CL https://golang.org/cl/9440 mentions this issue. |
Update #10305 Change-Id: Iea04758bc200038a1c64457a68100dcdd7f75212 Reviewed-on: https://go-review.googlesource.com/9440 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This has been documented. I don't believe there was more to do, but let me know if I'm wrong. |
Once an exec.Cmd has been Run (e.g. through .Run, .Output or .CombinedOutput) calling one of these run methods again will result in an error.
I'm not talking about parallel execution here, this is running, checking the output, then running again.
Example error message from calling CombinedOutput more than once:
"exec: Stdout already set."
http://play.golang.org/p/Aaj3Gbva_S
The text was updated successfully, but these errors were encountered: