diff options
author | Cherry Mui <cherryyz@google.com> | 2022-02-11 14:58:56 +0000 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2022-02-11 14:58:56 +0000 |
commit | e90b835f3071f1eb71810a3631b792f23df59f24 (patch) | |
tree | dc5a1c1620f14dbc051402095af9c024bc12a202 /misc | |
parent | bb93480d009322886df6f5185c988d6d21fdc2c8 (diff) | |
parent | 0a6cf8706fdd0fe1bd26e4d1ecbcd41650bf5e6c (diff) | |
download | go-e90b835f3071f1eb71810a3631b792f23df59f24.tar.gz go-e90b835f3071f1eb71810a3631b792f23df59f24.zip |
[dev.boringcrypto.go1.16] all: merge go1.16.14 into dev.boringcrypto.go1.16
Change-Id: I186a567b3e76df7ecf1842634a3851eab7c9dfce
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cgo/testplugin/plugin_test.go | 28 | ||||
-rw-r--r-- | misc/cgo/testplugin/testdata/forkexec/main.go | 30 |
2 files changed, 58 insertions, 0 deletions
diff --git a/misc/cgo/testplugin/plugin_test.go b/misc/cgo/testplugin/plugin_test.go index 8869528015..7b4df3f8ed 100644 --- a/misc/cgo/testplugin/plugin_test.go +++ b/misc/cgo/testplugin/plugin_test.go @@ -216,3 +216,31 @@ func TestIssue44956(t *testing.T) { goCmd(t, "build", "-o", "issue44956.exe", "./issue44956/main.go") run(t, "./issue44956.exe") } + +func TestForkExec(t *testing.T) { + // Issue 38824: importing the plugin package causes it hang in forkExec on darwin. + + t.Parallel() + goCmd(t, "build", "-o", "forkexec.exe", "./forkexec/main.go") + + var cmd *exec.Cmd + done := make(chan int, 1) + + go func() { + for i := 0; i < 100; i++ { + cmd = exec.Command("./forkexec.exe", "1") + err := cmd.Run() + if err != nil { + t.Errorf("running command failed: %v", err) + break + } + } + done <- 1 + }() + select { + case <-done: + case <-time.After(5 * time.Minute): + cmd.Process.Kill() + t.Fatalf("subprocess hang") + } +} diff --git a/misc/cgo/testplugin/testdata/forkexec/main.go b/misc/cgo/testplugin/testdata/forkexec/main.go new file mode 100644 index 0000000000..3169ff5f04 --- /dev/null +++ b/misc/cgo/testplugin/testdata/forkexec/main.go @@ -0,0 +1,30 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "os" + "os/exec" + _ "plugin" + "sync" +) + +func main() { + if os.Args[1] != "1" { + return + } + + var wg sync.WaitGroup + for i := 0; i < 8; i++ { + wg.Add(1) + go func() { + defer wg.Done() + // does not matter what we exec, just exec itself + cmd := exec.Command("./forkexec.exe", "0") + cmd.Run() + }() + } + wg.Wait() +} |