mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: treat SI_TKILL like SI_USER on Linux
On Linux a signal sent using tgkill will have si_code == SI_TKILL, not SI_USER. Treat the two cases the same. Add a Linux-specific test. Change the test to use the C pause function rather than sleeping for a second, as that achieves the same effect. Change-Id: I2a36646aecabcab9ec42ed9a048b07c2ff0a3987 Reviewed-on: https://go-review.googlesource.com/c/go/+/431255 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
a9ca741d31
commit
7c87012f04
10 changed files with 107 additions and 22 deletions
|
|
@ -662,7 +662,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||
if sig < uint32(len(sigtable)) {
|
||||
flags = sigtable[sig].flags
|
||||
}
|
||||
if c.sigcode() != _SI_USER && flags&_SigPanic != 0 && gp.throwsplit {
|
||||
if !c.sigFromUser() && flags&_SigPanic != 0 && gp.throwsplit {
|
||||
// We can't safely sigpanic because it may grow the
|
||||
// stack. Abort in the signal handler instead.
|
||||
flags = _SigThrow
|
||||
|
|
@ -672,7 +672,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||
// causes a memory fault. Don't turn that into a panic.
|
||||
flags = _SigThrow
|
||||
}
|
||||
if c.sigcode() != _SI_USER && flags&_SigPanic != 0 {
|
||||
if !c.sigFromUser() && flags&_SigPanic != 0 {
|
||||
// The signal is going to cause a panic.
|
||||
// Arrange the stack so that it looks like the point
|
||||
// where the signal occurred made a call to the
|
||||
|
|
@ -690,13 +690,13 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||
return
|
||||
}
|
||||
|
||||
if c.sigcode() == _SI_USER || flags&_SigNotify != 0 {
|
||||
if c.sigFromUser() || flags&_SigNotify != 0 {
|
||||
if sigsend(sig) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if c.sigcode() == _SI_USER && signal_ignored(sig) {
|
||||
if c.sigFromUser() && signal_ignored(sig) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -706,7 +706,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||
|
||||
// _SigThrow means that we should exit now.
|
||||
// If we get here with _SigPanic, it means that the signal
|
||||
// was sent to us by a program (c.sigcode() == _SI_USER);
|
||||
// was sent to us by a program (c.sigFromUser() is true);
|
||||
// in that case, if we didn't handle it in sigsend, we exit now.
|
||||
if flags&(_SigThrow|_SigPanic) == 0 {
|
||||
return
|
||||
|
|
@ -929,7 +929,7 @@ func raisebadsignal(sig uint32, c *sigctxt) {
|
|||
//
|
||||
// On FreeBSD, the libthr sigaction code prevents
|
||||
// this from working so we fall through to raise.
|
||||
if GOOS != "freebsd" && (isarchive || islibrary) && handler == _SIG_DFL && c.sigcode() != _SI_USER {
|
||||
if GOOS != "freebsd" && (isarchive || islibrary) && handler == _SIG_DFL && !c.sigFromUser() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1110,7 +1110,7 @@ func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool {
|
|||
// Unfortunately, user generated SIGPIPEs will also be forwarded, because si_code
|
||||
// is set to _SI_USER even for a SIGPIPE raised from a write to a closed socket
|
||||
// or pipe.
|
||||
if (c.sigcode() == _SI_USER || flags&_SigPanic == 0) && sig != _SIGPIPE {
|
||||
if (c.sigFromUser() || flags&_SigPanic == 0) && sig != _SIGPIPE {
|
||||
return false
|
||||
}
|
||||
// Determine if the signal occurred inside Go code. We test that:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue