aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2022-02-11 14:58:38 +0000
committerCherry Mui <cherryyz@google.com>2022-02-11 14:58:38 +0000
commit172559d22b5d9fe2dfbe9d4bf16ca0cb8f76c541 (patch)
treed11aa519e938cba7df7b379ddfceb2caff9bb020 /misc
parentcfad1ff84c45f99f6ceee17f76e2cbaf2ff8598b (diff)
parent6a70ee2873b2367e2a0d6e7d7e167c072b99daf0 (diff)
downloadgo-172559d22b5d9fe2dfbe9d4bf16ca0cb8f76c541.tar.gz
go-172559d22b5d9fe2dfbe9d4bf16ca0cb8f76c541.zip
[dev.boringcrypto.go1.17] all: merge go1.17.7 into dev.boringcrypto.go1.17
Change-Id: I6abebb215a38b5df450ef12281266bef6c8e76eb
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/testplugin/plugin_test.go28
-rw-r--r--misc/cgo/testplugin/testdata/forkexec/main.go30
2 files changed, 58 insertions, 0 deletions
diff --git a/misc/cgo/testplugin/plugin_test.go b/misc/cgo/testplugin/plugin_test.go
index ba4dd4cc4c..c8ded42b69 100644
--- a/misc/cgo/testplugin/plugin_test.go
+++ b/misc/cgo/testplugin/plugin_test.go
@@ -293,3 +293,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()
+}