diff options
| author | Bryan C. Mills <bcmills@google.com> | 2023-09-13 09:58:17 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-09-13 19:25:41 +0000 |
| commit | 36facaa1f9a24175f0fbe4fe5f479bbfb67d05e9 (patch) | |
| tree | 843219dc04d53fd0dd9898f5d7c18801c48f8ce6 /src/os/exec/exec_test.go | |
| parent | 6ecd5f750454665f789e3d557548bb5a65ad5c3a (diff) | |
| download | go-36facaa1f9a24175f0fbe4fe5f479bbfb67d05e9.tar.xz | |
os/exec: avoid writing to Cmd.Path in Cmd.Start on Windows
Fixes #62596.
Change-Id: I9003318ac1c4e3036f32383e62e9ba08c383d5c2
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-race,gotip-windows-amd64-race,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/527820
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/os/exec/exec_test.go')
| -rw-r--r-- | src/os/exec/exec_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 9783a133ba..71a00494ad 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -1819,3 +1819,19 @@ func TestConcurrentExec(t *testing.T) { cancel() hangs.Wait() } + +// TestPathRace tests that [Cmd.String] can be called concurrently +// with [Cmd.Start]. +func TestPathRace(t *testing.T) { + cmd := helperCommand(t, "exit", "0") + + done := make(chan struct{}) + go func() { + out, err := cmd.CombinedOutput() + t.Logf("%v: %v\n%s", cmd, err, out) + close(done) + }() + + t.Logf("running in background: %v", cmd) + <-done +} |
