aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/os
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-06-10 12:37:34 -0700
committerIan Lance Taylor <iant@golang.org>2021-06-10 14:41:23 -0700
commitee52bf609bac45b3c251858a69071262f46ee89c (patch)
tree4c079eab4884dc9c32e6f62fe9e2f0ff0d784306 /libgo/go/os
parent00d07ec6e12451acc7a290cd93be03bed50cb666 (diff)
downloadgcc-ee52bf609bac45b3c251858a69071262f46ee89c.zip
gcc-ee52bf609bac45b3c251858a69071262f46ee89c.tar.gz
gcc-ee52bf609bac45b3c251858a69071262f46ee89c.tar.bz2
libgo: update to Go1.16.5 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/326772
Diffstat (limited to 'libgo/go/os')
-rw-r--r--libgo/go/os/signal/signal_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/libgo/go/os/signal/signal_test.go b/libgo/go/os/signal/signal_test.go
index db94756..1f89780 100644
--- a/libgo/go/os/signal/signal_test.go
+++ b/libgo/go/os/signal/signal_test.go
@@ -15,6 +15,7 @@ import (
"os"
"os/exec"
"runtime"
+ "runtime/trace"
"strconv"
"sync"
"syscall"
@@ -853,3 +854,44 @@ func TestNotifyContextStringer(t *testing.T) {
t.Errorf("c.String() = %q, want %q", got, want)
}
}
+
+// #44193 test signal handling while stopping and starting the world.
+func TestSignalTrace(t *testing.T) {
+ done := make(chan struct{})
+ quit := make(chan struct{})
+ c := make(chan os.Signal, 1)
+ Notify(c, syscall.SIGHUP)
+
+ // Source and sink for signals busy loop unsynchronized with
+ // trace starts and stops. We are ultimately validating that
+ // signals and runtime.(stop|start)TheWorldGC are compatible.
+ go func() {
+ defer close(done)
+ defer Stop(c)
+ pid := syscall.Getpid()
+ for {
+ select {
+ case <-quit:
+ return
+ default:
+ syscall.Kill(pid, syscall.SIGHUP)
+ }
+ waitSig(t, c, syscall.SIGHUP)
+ }
+ }()
+
+ for i := 0; i < 100; i++ {
+ buf := new(bytes.Buffer)
+ if err := trace.Start(buf); err != nil {
+ t.Fatalf("[%d] failed to start tracing: %v", i, err)
+ }
+ time.After(1 * time.Microsecond)
+ trace.Stop()
+ size := buf.Len()
+ if size == 0 {
+ t.Fatalf("[%d] trace is empty", i)
+ }
+ }
+ close(quit)
+ <-done
+}