1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package runtime 6 7 import "unsafe" 8 9 type sigTabT struct { 10 flags int32 11 name string 12 } 13 14 var sigtable = [...]sigTabT{ 15 /* 0 */ {0, "SIGNONE: no trap"}, 16 /* 1 */ {_SigNotify + _SigKill, "SIGHUP: terminal line hangup"}, 17 /* 2 */ {_SigNotify + _SigKill, "SIGINT: interrupt"}, 18 /* 3 */ {_SigNotify + _SigThrow, "SIGQUIT: quit"}, 19 /* 4 */ {_SigThrow + _SigUnblock, "SIGILL: illegal instruction"}, 20 /* 5 */ {_SigThrow + _SigUnblock, "SIGTRAP: trace trap"}, 21 /* 6 */ {_SigNotify + _SigThrow, "SIGABRT: abort"}, 22 /* 7 */ {_SigThrow, "SIGEMT: emulate instruction executed"}, 23 /* 8 */ {_SigPanic + _SigUnblock, "SIGFPE: floating-point exception"}, 24 /* 9 */ {0, "SIGKILL: kill"}, 25 /* 10 */ {_SigPanic + _SigUnblock, "SIGBUS: bus error"}, 26 /* 11 */ {_SigPanic + _SigUnblock, "SIGSEGV: segmentation violation"}, 27 /* 12 */ {_SigThrow, "SIGSYS: bad system call"}, 28 /* 13 */ {_SigNotify, "SIGPIPE: write to broken pipe"}, 29 /* 14 */ {_SigNotify, "SIGALRM: alarm clock"}, 30 /* 15 */ {_SigNotify + _SigKill, "SIGTERM: termination"}, 31 /* 16 */ {_SigNotify, "SIGURG: urgent condition on socket"}, 32 /* 17 */ {0, "SIGSTOP: stop"}, 33 /* 18 */ {_SigNotify + _SigDefault, "SIGTSTP: keyboard stop"}, 34 /* 19 */ {0, "SIGCONT: continue after stop"}, 35 /* 20 */ {_SigNotify + _SigUnblock, "SIGCHLD: child status has changed"}, 36 /* 21 */ {_SigNotify + _SigDefault, "SIGTTIN: background read from tty"}, 37 /* 22 */ {_SigNotify + _SigDefault, "SIGTTOU: background write to tty"}, 38 /* 23 */ {_SigNotify, "SIGIO: i/o now possible"}, 39 /* 24 */ {_SigNotify, "SIGXCPU: cpu limit exceeded"}, 40 /* 25 */ {_SigNotify, "SIGXFSZ: file size limit exceeded"}, 41 /* 26 */ {_SigNotify, "SIGVTALRM: virtual alarm clock"}, 42 /* 27 */ {_SigNotify + _SigUnblock, "SIGPROF: profiling alarm clock"}, 43 /* 28 */ {_SigNotify, "SIGWINCH: window size change"}, 44 /* 29 */ {_SigNotify, "SIGINFO: status request from keyboard"}, 45 /* 30 */ {_SigNotify, "SIGUSR1: user-defined signal 1"}, 46 /* 31 */ {_SigNotify, "SIGUSR2: user-defined signal 2"}, 47 } 48 49 //go:noescape 50 func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer) 51 52 //go:noescape 53 func sigreturn(ctx unsafe.Pointer, infostyle uint32) 54 55 //go:nosplit 56 func sigtrampgo(fn uintptr, infostyle, sig uint32, info *siginfo, ctx unsafe.Pointer) { 57 if sigfwdgo(sig, info, ctx) { 58 sigreturn(ctx, infostyle) 59 return 60 } 61 g := getg() 62 if g == nil { 63 badsignal(uintptr(sig)) 64 sigreturn(ctx, infostyle) 65 return 66 } 67 setg(g.m.gsignal) 68 sighandler(sig, info, ctx, g) 69 setg(g) 70 sigreturn(ctx, infostyle) 71 } 72