+
+/*
+ * Signal name manipulation.
+ */
+
+private String signames[NSIG] = {
+ 0,
+ "HUP", "INT", "QUIT", "ILL", "TRAP",
+ "IOT", "EMT", "FPE", "KILL", "BUS",
+ "SEGV", "SYS", "PIPE", "ALRM", "TERM",
+ 0, "STOP", "TSTP", "CONT", "CHLD",
+ "TTIN", "TTOU", "TINT", "XCPU", "XFSZ",
+ "VTALRM", "PROF", "WINCH", "USR1", "USR2"
+};
+
+/*
+ * Get the signal number associated with a given name.
+ * The name is first translated to upper case if necessary.
+ */
+
+public integer siglookup (s)
+String s;
+{
+ register char *p, *q;
+ char buf[100];
+ integer i;
+
+ p = s;
+ q = buf;
+ while (*p != '\0') {
+ if (*p >= 'a' and *p <= 'z') {
+ *q = (*p - 'a') + 'A';
+ } else {
+ *q = *p;
+ }
+ ++p;
+ ++q;
+ }
+ *q = '\0';
+ p = buf;
+ if (buf[0] == 'S' and buf[1] == 'I' and buf[2] == 'G') {
+ p += 3;
+ }
+ i = 1;
+ for (;;) {
+ if (i >= sizeof(signames) div sizeof(signames[0])) {
+ error("signal \"%s\" unknown", s);
+ i = 0;
+ break;
+ }
+ if (signames[i] != nil and streq(signames[i], p)) {
+ break;
+ }
+ ++i;
+ }
+ return i;
+}
+
+/*
+ * Print all signals being ignored by the debugger.
+ * These signals are auotmatically
+ * passed on to the debugged process.
+ */
+
+public printsigsignored (p)
+Process p;
+{
+ printsigs(~p->sigset);
+}
+
+/*
+ * Print all signals being intercepted by
+ * the debugger for the specified process.
+ */
+
+public printsigscaught(p)
+Process p;
+{
+ printsigs(p->sigset);
+}
+
+private printsigs (set)
+integer set;
+{
+ integer s;
+ char separator[2];
+
+ separator[0] = '\0';
+ for (s = 1; s < sizeof(signames) div sizeof(signames[0]); s++) {
+ if (set & setrep(s)) {
+ if (signames[s] != nil) {
+ printf("%s%s", separator, signames[s]);
+ separator[0] = ' ';
+ separator[1] = '\0';
+ }
+ }
+ }
+ if (separator[0] == ' ') {
+ putchar('\n');
+ }
+}