]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't always unblock all signals on dragonfly, freebsd and openbsd
authorMikio Hara <mikioh.mikioh@gmail.com>
Fri, 15 Jan 2016 05:57:41 +0000 (14:57 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Fri, 15 Apr 2016 21:20:45 +0000 (21:20 +0000)
https://golang.org/cl/10173 intrduced msigsave, ensureSigM and
_SigUnblock but didn't enable the new signal save/restore mechanism for
SIG{HUP,INT,QUIT,ABRT,TERM} on DragonFly BSD, FreeBSD and OpenBSD.

At present, it looks like they have the implementation. This change
enables the new mechanism on DragonFly BSD, FreeBSD and OpenBSD the same
as Darwin, NetBSD.

Change-Id: Ifb4b4743b3b4f50bfcdc7cf1fe1b59c377fa2a41
Reviewed-on: https://go-review.googlesource.com/18657
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/test/cgo_linux_test.go
misc/cgo/test/cgo_unix_test.go
misc/cgo/test/sigprocmask.c [moved from misc/cgo/test/sigprocmask_linux.c with 97% similarity]
misc/cgo/test/sigprocmask.go [moved from misc/cgo/test/sigprocmask_linux.go with 92% similarity]
src/runtime/signal_dragonfly.go
src/runtime/signal_freebsd.go
src/runtime/signal_openbsd.go

index 3cc2af5919c21ac31d55376afbaccee41c87926b..6e1d1065f63bbcca821c79267743f1a1c718f2c6 100644 (file)
@@ -6,8 +6,7 @@ package cgotest
 
 import "testing"
 
-func TestSetgid(t *testing.T)      { testSetgid(t) }
-func Test6997(t *testing.T)        { test6997(t) }
-func TestBuildID(t *testing.T)     { testBuildID(t) }
-func Test9400(t *testing.T)        { test9400(t) }
-func TestSigProcMask(t *testing.T) { testSigProcMask(t) }
+func TestSetgid(t *testing.T)  { testSetgid(t) }
+func Test6997(t *testing.T)    { test6997(t) }
+func TestBuildID(t *testing.T) { testBuildID(t) }
+func Test9400(t *testing.T)    { test9400(t) }
index 5808e6edc83a5d8d8e51e224c34045b74d88fcaf..5fe3251e0b80f9031d3dbaf920a0c3a38f0c72bd 100644 (file)
@@ -9,3 +9,4 @@ package cgotest
 import "testing"
 
 func TestSigaltstack(t *testing.T) { testSigaltstack(t) }
+func TestSigprocmask(t *testing.T) { testSigprocmask(t) }
similarity index 97%
rename from misc/cgo/test/sigprocmask_linux.c
rename to misc/cgo/test/sigprocmask.c
index 518c533fa4d31b7d0e9a08b7b0fc841e63172fb6..bd99647d2b386476eedb996430b29d6fa79a1b96 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build !windows
+
 #include <signal.h>
 #include <stdlib.h>
 #include <pthread.h>
similarity index 92%
rename from misc/cgo/test/sigprocmask_linux.go
rename to misc/cgo/test/sigprocmask.go
index 7d343e92c458fdc6d24df48e0ced7a53ebd02247..39b658e96c3c0c4c9ba3afb5b794951333b523ec 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build !windows
+
 package cgotest
 
 /*
@@ -28,7 +30,7 @@ func IntoGoAndBack() {
        blocked = C.CheckBlocked() != 0
 }
 
-func testSigProcMask(t *testing.T) {
+func testSigprocmask(t *testing.T) {
        if r := C.RunSigThread(); r != 0 {
                t.Error("pthread_create/pthread_join failed")
        }
index f507a07233c6034858ac647424d91c1e86dd8b52..8e9ce17c86bc3503d1159d242abdf11ba16030b6 100644 (file)
@@ -14,14 +14,14 @@ var sigtable = [...]sigTabT{
        /* 1 */ {_SigNotify + _SigKill, "SIGHUP: terminal line hangup"},
        /* 2 */ {_SigNotify + _SigKill, "SIGINT: interrupt"},
        /* 3 */ {_SigNotify + _SigThrow, "SIGQUIT: quit"},
-       /* 4 */ {_SigThrow, "SIGILL: illegal instruction"},
-       /* 5 */ {_SigThrow, "SIGTRAP: trace trap"},
+       /* 4 */ {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"},
+       /* 5 */ {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"},
        /* 6 */ {_SigNotify + _SigThrow, "SIGABRT: abort"},
        /* 7 */ {_SigThrow, "SIGEMT: emulate instruction executed"},
-       /* 8 */ {_SigPanic, "SIGFPE: floating-point exception"},
+       /* 8 */ {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"},
        /* 9 */ {0, "SIGKILL: kill"},
-       /* 10 */ {_SigPanic, "SIGBUS: bus error"},
-       /* 11 */ {_SigPanic, "SIGSEGV: segmentation violation"},
+       /* 10 */ {_SigPanic + _SigUnblock, "SIGBUS: bus error"},
+       /* 11 */ {_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"},
        /* 12 */ {_SigThrow, "SIGSYS: bad system call"},
        /* 13 */ {_SigNotify, "SIGPIPE: write to broken pipe"},
        /* 14 */ {_SigNotify, "SIGALRM: alarm clock"},
@@ -30,14 +30,14 @@ var sigtable = [...]sigTabT{
        /* 17 */ {0, "SIGSTOP: stop"},
        /* 18 */ {_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"},
        /* 19 */ {_SigNotify + _SigDefault, "SIGCONT: continue after stop"},
-       /* 20 */ {_SigNotify, "SIGCHLD: child status has changed"},
+       /* 20 */ {_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"},
        /* 21 */ {_SigNotify + _SigDefault, "SIGTTIN: background read from tty"},
        /* 22 */ {_SigNotify + _SigDefault, "SIGTTOU: background write to tty"},
        /* 23 */ {_SigNotify, "SIGIO: i/o now possible"},
        /* 24 */ {_SigNotify, "SIGXCPU: cpu limit exceeded"},
        /* 25 */ {_SigNotify, "SIGXFSZ: file size limit exceeded"},
        /* 26 */ {_SigNotify, "SIGVTALRM: virtual alarm clock"},
-       /* 27 */ {_SigNotify, "SIGPROF: profiling alarm clock"},
+       /* 27 */ {_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"},
        /* 28 */ {_SigNotify, "SIGWINCH: window size change"},
        /* 29 */ {_SigNotify, "SIGINFO: status request from keyboard"},
        /* 30 */ {_SigNotify, "SIGUSR1: user-defined signal 1"},
index cd2068a62c04985567fd43b9ec51d57c7b63b87d..c8b09e92d9ac55b73735265abeb57f7e0479ae91 100644 (file)
@@ -16,14 +16,14 @@ var sigtable = [...]sigTabT{
        /* 1 */ {_SigNotify + _SigKill, "SIGHUP: terminal line hangup"},
        /* 2 */ {_SigNotify + _SigKill, "SIGINT: interrupt"},
        /* 3 */ {_SigNotify + _SigThrow, "SIGQUIT: quit"},
-       /* 4 */ {_SigThrow, "SIGILL: illegal instruction"},
-       /* 5 */ {_SigThrow, "SIGTRAP: trace trap"},
+       /* 4 */ {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"},
+       /* 5 */ {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"},
        /* 6 */ {_SigNotify + _SigThrow, "SIGABRT: abort"},
        /* 7 */ {_SigThrow, "SIGEMT: emulate instruction executed"},
-       /* 8 */ {_SigPanic, "SIGFPE: floating-point exception"},
+       /* 8 */ {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"},
        /* 9 */ {0, "SIGKILL: kill"},
-       /* 10 */ {_SigPanic, "SIGBUS: bus error"},
-       /* 11 */ {_SigPanic, "SIGSEGV: segmentation violation"},
+       /* 10 */ {_SigPanic + _SigUnblock, "SIGBUS: bus error"},
+       /* 11 */ {_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"},
        /* 12 */ {_SigNotify, "SIGSYS: bad system call"},
        /* 13 */ {_SigNotify, "SIGPIPE: write to broken pipe"},
        /* 14 */ {_SigNotify, "SIGALRM: alarm clock"},
@@ -32,14 +32,14 @@ var sigtable = [...]sigTabT{
        /* 17 */ {0, "SIGSTOP: stop"},
        /* 18 */ {_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"},
        /* 19 */ {_SigNotify + _SigDefault, "SIGCONT: continue after stop"},
-       /* 20 */ {_SigNotify, "SIGCHLD: child status has changed"},
+       /* 20 */ {_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"},
        /* 21 */ {_SigNotify + _SigDefault, "SIGTTIN: background read from tty"},
        /* 22 */ {_SigNotify + _SigDefault, "SIGTTOU: background write to tty"},
        /* 23 */ {_SigNotify, "SIGIO: i/o now possible"},
        /* 24 */ {_SigNotify, "SIGXCPU: cpu limit exceeded"},
        /* 25 */ {_SigNotify, "SIGXFSZ: file size limit exceeded"},
        /* 26 */ {_SigNotify, "SIGVTALRM: virtual alarm clock"},
-       /* 27 */ {_SigNotify, "SIGPROF: profiling alarm clock"},
+       /* 27 */ {_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"},
        /* 28 */ {_SigNotify, "SIGWINCH: window size change"},
        /* 29 */ {_SigNotify, "SIGINFO: status request from keyboard"},
        /* 30 */ {_SigNotify, "SIGUSR1: user-defined signal 1"},
index 3c50190da44449ffe936647d5b359b7667c8c7d3..9275279860f4b6ed31d997e33d53c13f241c0d5d 100644 (file)
@@ -16,14 +16,14 @@ var sigtable = [...]sigTabT{
        /*  1 */ {_SigNotify + _SigKill, "SIGHUP: terminal line hangup"},
        /*  2 */ {_SigNotify + _SigKill, "SIGINT: interrupt"},
        /*  3 */ {_SigNotify + _SigThrow, "SIGQUIT: quit"},
-       /*  4 */ {_SigThrow, "SIGILL: illegal instruction"},
-       /*  5 */ {_SigThrow, "SIGTRAP: trace trap"},
+       /*  4 */ {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"},
+       /*  5 */ {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"},
        /*  6 */ {_SigNotify + _SigThrow, "SIGABRT: abort"},
        /*  7 */ {_SigThrow, "SIGEMT: emulate instruction executed"},
-       /*  8 */ {_SigPanic, "SIGFPE: floating-point exception"},
+       /*  8 */ {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"},
        /*  9 */ {0, "SIGKILL: kill"},
-       /* 10 */ {_SigPanic, "SIGBUS: bus error"},
-       /* 11 */ {_SigPanic, "SIGSEGV: segmentation violation"},
+       /* 10 */ {_SigPanic + _SigUnblock, "SIGBUS: bus error"},
+       /* 11 */ {_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"},
        /* 12 */ {_SigThrow, "SIGSYS: bad system call"},
        /* 13 */ {_SigNotify, "SIGPIPE: write to broken pipe"},
        /* 14 */ {_SigNotify, "SIGALRM: alarm clock"},
@@ -32,14 +32,14 @@ var sigtable = [...]sigTabT{
        /* 17 */ {0, "SIGSTOP: stop"},
        /* 18 */ {_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"},
        /* 19 */ {_SigNotify + _SigDefault, "SIGCONT: continue after stop"},
-       /* 20 */ {_SigNotify, "SIGCHLD: child status has changed"},
+       /* 20 */ {_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"},
        /* 21 */ {_SigNotify + _SigDefault, "SIGTTIN: background read from tty"},
        /* 22 */ {_SigNotify + _SigDefault, "SIGTTOU: background write to tty"},
        /* 23 */ {_SigNotify, "SIGIO: i/o now possible"},
        /* 24 */ {_SigNotify, "SIGXCPU: cpu limit exceeded"},
        /* 25 */ {_SigNotify, "SIGXFSZ: file size limit exceeded"},
        /* 26 */ {_SigNotify, "SIGVTALRM: virtual alarm clock"},
-       /* 27 */ {_SigNotify, "SIGPROF: profiling alarm clock"},
+       /* 27 */ {_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"},
        /* 28 */ {_SigNotify, "SIGWINCH: window size change"},
        /* 29 */ {_SigNotify, "SIGINFO: status request from keyboard"},
        /* 30 */ {_SigNotify, "SIGUSR1: user-defined signal 1"},