summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/signals_plan9.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/signals_plan9.h')
-rw-r--r--src/pkg/runtime/signals_plan9.h60
1 files changed, 46 insertions, 14 deletions
diff --git a/src/pkg/runtime/signals_plan9.h b/src/pkg/runtime/signals_plan9.h
index f9bec65fc..818f508cf 100644
--- a/src/pkg/runtime/signals_plan9.h
+++ b/src/pkg/runtime/signals_plan9.h
@@ -3,26 +3,58 @@
// license that can be found in the LICENSE file.
#define N SigNotify
+#define K SigKill
#define T SigThrow
#define P SigPanic
+#define E SigGoExit
+
+// Incoming notes are compared against this table using strncmp, so the
+// order matters: longer patterns must appear before their prefixes.
+// There are #defined SIG constants in os_plan9.h for the table index of
+// some of these.
+//
+// If you add entries to this table, you must respect the prefix ordering
+// and also update the constant values is os_plan9.h.
SigTab runtime·sigtab[] = {
- P, "sys: fp:",
-
- // Go libraries expect to be able
- // to recover from memory
- // read/write errors, so we flag
- // those as panics. All other traps
- // are generally more serious and
- // should immediately throw an
- // exception.
- P, "sys: trap: fault read addr",
- P, "sys: trap: fault write addr",
- T, "sys: trap:",
-
- N, "sys: bad sys call",
+ // Traps that we cannot be recovered.
+ T, "sys: trap: debug exception",
+ T, "sys: trap: invalid opcode",
+
+ // We can recover from some memory errors in runtime·sigpanic.
+ P, "sys: trap: fault read addr", // SIGRFAULT
+ P, "sys: trap: fault write addr", // SIGWFAULT
+
+ // We can also recover from math errors.
+ P, "sys: trap: divide error", // SIGINTDIV
+ P, "sys: fp:", // SIGFLOAT
+
+ // All other traps are normally handled as if they were marked SigThrow.
+ // We mark them SigPanic here so that debug.SetPanicOnFault will work.
+ P, "sys: trap:", // SIGTRAP
+
+ // Writes to a closed pipe can be handled if desired, otherwise they're ignored.
+ N, "sys: write on closed pipe",
+
+ // Other system notes are more serious and cannot be recovered.
+ T, "sys:",
+
+ // Issued to all other procs when calling runtime·exit.
+ E, "go: exit ",
+
+ // Kill is sent by external programs to cause an exit.
+ K, "kill",
+
+ // Interrupts can be handled if desired, otherwise they cause an exit.
+ N+K, "interrupt",
+ N+K, "hangup",
+
+ // Alarms can be handled if desired, otherwise they're ignored.
+ N, "alarm",
};
#undef N
+#undef K
#undef T
#undef P
+#undef E