aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec_windows.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2022-04-22 22:00:16 -0400
committerBryan Mills <bcmills@google.com>2022-04-26 13:47:05 +0000
commitad5eaa8c4cd952df0d4894f11ee0158a9a33a0f3 (patch)
tree5d03dab465bf4a313f4d007f01f0644bb6bb2005 /src/os/exec/exec_windows.go
parent17d7983b29ba633708a9d7b18f90ab5bc029502d (diff)
downloadgo-ad5eaa8c4cd952df0d4894f11ee0158a9a33a0f3.tar.xz
os/exec: make skipStdinCopyError a function instead of a variable
This makes clearer that skipStdinCopyError is always defined and never overridden in tests. Secondarily, it may also help reduce init-time work and allow the linker and/or inliner to better optimize this package. (Noticed while prototyping #50436.) Change-Id: I4f3c1bc146384a98136a4039f82165ed106c14b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/401897 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/os/exec/exec_windows.go')
-rw-r--r--src/os/exec/exec_windows.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/os/exec/exec_windows.go b/src/os/exec/exec_windows.go
index bb937f8aed..e7a2ee6c9d 100644
--- a/src/os/exec/exec_windows.go
+++ b/src/os/exec/exec_windows.go
@@ -9,15 +9,15 @@ import (
"syscall"
)
-func init() {
- skipStdinCopyError = func(err error) bool {
- // Ignore ERROR_BROKEN_PIPE and ERROR_NO_DATA errors copying
- // to stdin if the program completed successfully otherwise.
- // See Issue 20445.
- const _ERROR_NO_DATA = syscall.Errno(0xe8)
- pe, ok := err.(*fs.PathError)
- return ok &&
- pe.Op == "write" && pe.Path == "|1" &&
- (pe.Err == syscall.ERROR_BROKEN_PIPE || pe.Err == _ERROR_NO_DATA)
- }
+// skipStdinCopyError optionally specifies a function which reports
+// whether the provided stdin copy error should be ignored.
+func skipStdinCopyError(err error) bool {
+ // Ignore ERROR_BROKEN_PIPE and ERROR_NO_DATA errors copying
+ // to stdin if the program completed successfully otherwise.
+ // See Issue 20445.
+ const _ERROR_NO_DATA = syscall.Errno(0xe8)
+ pe, ok := err.(*fs.PathError)
+ return ok &&
+ pe.Op == "write" && pe.Path == "|1" &&
+ (pe.Err == syscall.ERROR_BROKEN_PIPE || pe.Err == _ERROR_NO_DATA)
}