]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: ignore GNU/Linux sigaction errors for signals 32 and 33
authorIan Lance Taylor <iant@golang.org>
Wed, 25 Jul 2018 21:09:02 +0000 (14:09 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 25 Jul 2018 21:30:24 +0000 (21:30 +0000)
This avoids problems when running under QEMU. It seems that at least
some QEMU versions turn the sigaction implementation into a call to
the C library sigaction function. The C library function will reject
attempts to set the signal handler for signals 32 and 33. Ignore
errors in that case.

Change-Id: Id443a9a32f6fb0ceef5c59a398e7ede30bf71646
Reviewed-on: https://go-review.googlesource.com/125955
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/os_linux.go

index 68f99de115d4387d6042dc1cf6e0a90022c0267b..a04c995c008c9ce96e70824e04143d0836172428 100644 (file)
@@ -415,9 +415,18 @@ func (c *sigctxt) fixsigcode(sig uint32) {
 //go:nosplit
 func sysSigaction(sig uint32, new, old *sigactiont) {
        if rt_sigaction(uintptr(sig), new, old, unsafe.Sizeof(sigactiont{}.sa_mask)) != 0 {
-               // Workaround for bug in Qemu user mode emulation. (qemu
-               // rejects rt_sigaction of signal 64, SIGRTMAX).
-               if sig != 64 {
+               // Workaround for bugs in QEMU user mode emulation.
+               //
+               // QEMU turns calls to the sigaction system call into
+               // calls to the C library sigaction call; the C
+               // library call rejects attempts to call sigaction for
+               // SIGCANCEL (32) or SIGSETXID (33).
+               //
+               // QEMU rejects calling sigaction on SIGRTMAX (64).
+               //
+               // Just ignore the error in these case. There isn't
+               // anything we can do about it anyhow.
+               if sig != 32 && sig != 33 && sig != 64 {
                        // Use system stack to avoid split stack overflow on ppc64/ppc64le.
                        systemstack(func() {
                                throw("sigaction failed")