David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 1 | // Copyright 2011 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 | type sigTabT struct { |
| 8 | flags int |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 9 | name string |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 10 | } |
| 11 | |
| 12 | // Incoming notes are compared against this table using strncmp, so the |
| 13 | // order matters: longer patterns must appear before their prefixes. |
| 14 | // There are _SIG constants in os2_plan9.go for the table index of some |
| 15 | // of these. |
| 16 | // |
| 17 | // If you add entries to this table, you must respect the prefix ordering |
| 18 | // and also update the constant values is os2_plan9.go. |
| 19 | var sigtable = [...]sigTabT{ |
| 20 | // Traps that we cannot be recovered. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 21 | {_SigThrow, "sys: trap: debug exception"}, |
| 22 | {_SigThrow, "sys: trap: invalid opcode"}, |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 23 | |
| 24 | // We can recover from some memory errors in runtime·sigpanic. |
Richard Miller | d145456 | 2016-01-27 18:43:36 +0000 | [diff] [blame] | 25 | {_SigPanic, "sys: trap: fault read"}, // SIGRFAULT |
| 26 | {_SigPanic, "sys: trap: fault write"}, // SIGWFAULT |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 27 | |
| 28 | // We can also recover from math errors. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 29 | {_SigPanic, "sys: trap: divide error"}, // SIGINTDIV |
| 30 | {_SigPanic, "sys: fp:"}, // SIGFLOAT |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 31 | |
| 32 | // All other traps are normally handled as if they were marked SigThrow. |
| 33 | // We mark them SigPanic here so that debug.SetPanicOnFault will work. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 34 | {_SigPanic, "sys: trap:"}, // SIGTRAP |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 35 | |
| 36 | // Writes to a closed pipe can be handled if desired, otherwise they're ignored. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 37 | {_SigNotify, "sys: write on closed pipe"}, |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 38 | |
| 39 | // Other system notes are more serious and cannot be recovered. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 40 | {_SigThrow, "sys:"}, |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 41 | |
| 42 | // Issued to all other procs when calling runtime·exit. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 43 | {_SigGoExit, "go: exit "}, |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 44 | |
| 45 | // Kill is sent by external programs to cause an exit. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 46 | {_SigKill, "kill"}, |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 47 | |
| 48 | // Interrupts can be handled if desired, otherwise they cause an exit. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 49 | {_SigNotify + _SigKill, "interrupt"}, |
| 50 | {_SigNotify + _SigKill, "hangup"}, |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 51 | |
| 52 | // Alarms can be handled if desired, otherwise they're ignored. |
Matthew Dempsky | 7b36227 | 2015-02-13 12:09:12 +0900 | [diff] [blame] | 53 | {_SigNotify, "alarm"}, |
David du Colombier | d093bf4 | 2015-10-24 18:14:51 +0200 | [diff] [blame] | 54 | |
| 55 | // Aborts can be handled if desired, otherwise they cause a stack trace. |
| 56 | {_SigNotify + _SigThrow, "abort"}, |
David du Colombier | e9c57d8 | 2014-11-21 19:39:01 +0100 | [diff] [blame] | 57 | } |