aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/crash_unix_test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-06-12 22:36:03 -0700
committerIan Lance Taylor <iant@golang.org>2017-06-14 14:00:56 +0000
commitdf0892cbf854e76fae6e875043b05c194e37f52d (patch)
tree6d2ff62cf209f0f5bcaad476715d14a3caf8d667 /src/runtime/crash_unix_test.go
parent17ba830f4663816c3270860fad96373a833a3b26 (diff)
downloadgo-df0892cbf854e76fae6e875043b05c194e37f52d.tar.gz
go-df0892cbf854e76fae6e875043b05c194e37f52d.zip
runtime, syscall: reset signal handlers to default in child
Block all signals during a fork. In the parent process, after the fork, restore the signal mask. In the child process, reset all currently handled signals to the default handler, and then restore the signal mask. The effect of this is that the child will be operating using the same signal regime as the program it is about to exec, as exec resets all non-ignored signals to the default, and preserves the signal mask. We do this so that in the case of a signal sent to the process group, the child process will not try to run a signal handler while in the precarious state after a fork. Fixes #18600. Change-Id: I9f39aaa3884035908d687ee323c975f349d5faaa Reviewed-on: https://go-review.googlesource.com/45471 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/crash_unix_test.go')
-rw-r--r--src/runtime/crash_unix_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/runtime/crash_unix_test.go b/src/runtime/crash_unix_test.go
index 182c84b639..fdb3267006 100644
--- a/src/runtime/crash_unix_test.go
+++ b/src/runtime/crash_unix_test.go
@@ -251,3 +251,16 @@ func TestSignalIgnoreSIGTRAP(t *testing.T) {
t.Fatalf("want %s, got %s\n", want, output)
}
}
+
+func TestSignalDuringExec(t *testing.T) {
+ switch runtime.GOOS {
+ case "darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd":
+ default:
+ t.Skipf("skipping test on %s", runtime.GOOS)
+ }
+ output := runTestProg(t, "testprognet", "SignalDuringExec")
+ want := "OK\n"
+ if output != want {
+ t.Fatalf("want %s, got %s\n", want, output)
+ }
+}