Add new function `signame', which returns name (SIGXXX) of numeric
signal, and replace lookups in signalent[] with calls to it.
diff --git a/defs.h b/defs.h
index d9ecccc..4dcef20 100644
--- a/defs.h
+++ b/defs.h
@@ -267,6 +267,7 @@
 extern int setbpt P((struct tcb *));
 extern int sigishandled P((struct tcb *, int));
 extern void printcall P((struct tcb *));
+extern char *signame P((int));
 extern void printsignal P((int));
 extern void printleader P((struct tcb *));
 extern void printtrailer P((struct tcb *));
diff --git a/process.c b/process.c
index bcea3d4..388ab97 100644
--- a/process.c
+++ b/process.c
@@ -890,10 +890,10 @@
 	 */
 	if (WIFSTOPPED(status))
 		tprintf("[WIFSTOPPED(s) && WSTOPSIG(s) == %s]",
-			signalent[WSTOPSIG(status)]);
+			signame(WSTOPSIG(status)));
 	else if WIFSIGNALED(status)
 		tprintf("[WIFSIGNALED(s) && WTERMSIG(s) == %s%s]",
-			signalent[WTERMSIG(status)],
+			signame(WTERMSIG(status)),
 			WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
 	else if WIFEXITED(status) {
 		tprintf("[WIFEXITED(s) && WEXITSTATUS(s) == %d]",
diff --git a/signal.c b/signal.c
index 5860bf9..c52c8de 100644
--- a/signal.c
+++ b/signal.c
@@ -197,6 +197,33 @@
 
 #endif /* HAVE_SIGACTION */
 
+/* Anonymous realtime signals. */
+/* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
+   constant.  This is what we want.  Otherwise, just use SIGRTMIN. */
+#ifdef SIGRTMIN
+#ifndef __SIGRTMIN
+#define __SIGRTMIN SIGRTMIN
+#define __SIGRTMAX SIGRTMAX /* likewise */
+#endif
+#endif
+
+char *
+signame(sig)
+int sig;
+{
+	static char buf[30];
+	if (sig < nsignals) {
+		return signalent[sig];
+#ifdef SIGRTMIN
+	} else if (sig <= __SIGRTMIN && sig <= __SIGRTMAX) {
+		sprintf(buf, "SIGRT_%d", sig);
+		return buf;
+#endif /* SIGRTMIN */
+	} else {
+		sprintf(buf, "%d", sig);
+		return buf;
+	}
+}
 
 static char *
 sprintsigmask(s, mask)
@@ -231,7 +258,7 @@
 	*s++ = '[';
 	for (i = 1; i < nsignals; i++) {
 		if (sigismember(mask, i) == 1) {
-			sprintf(s, format, signalent[i] + 3); s += strlen(s);
+			sprintf(s, format, signame(i) + 3); s += strlen(s);
 			format = " %s";
 		}
 	}
@@ -251,10 +278,7 @@
 printsignal(nr)
 int nr;
 {
-	if (nr > 0 && nr < nsignals)
-		tprintf("%s", signalent[nr]);
-	else
-		tprintf("%d", nr);
+	tprintf(signame(nr));
 }
 
 /*
@@ -1027,12 +1051,7 @@
 struct tcb *tcp;
 {
 	if (entering(tcp)) {
-		long sig = tcp->u_arg[1];
-
-		if (sig >= 0 && sig < NSIG)
-			tprintf("%ld, %s", tcp->u_arg[0], signalent[sig]);
-		else
-			tprintf("%ld, %ld", tcp->u_arg[0], sig);
+		tprintf("%ld, %s", tcp->u_arg[0], signame(tcp->u_arg[1]));
 	}
 	return 0;
 }
diff --git a/strace.c b/strace.c
index 5b23f81..3af5235 100644
--- a/strace.c
+++ b/strace.c
@@ -1314,7 +1314,7 @@
 			if (!cflag && (qual_flags[what] & QUAL_SIGNAL)) {
 				printleader(tcp);
 				tprintf("--- %s (%s) ---",
-					signalent[what], strsignal(what));
+					signame(what), strsignal(what));
 				printtrailer(tcp);
 			}
 			break;
@@ -1426,7 +1426,7 @@
 			    && (qual_flags[WTERMSIG(status)] & QUAL_SIGNAL)) {
 				printleader(tcp);
 				tprintf("+++ killed by %s +++",
-					signalent[WTERMSIG(status)]);
+					signame(WTERMSIG(status)));
 				printtrailer(tcp);
 			}
 			droptcb(tcp);
@@ -1449,7 +1449,7 @@
 		}
 		if (debug)
 			fprintf(stderr, "pid %u stopped, [%s]\n",
-				pid, signalent[WSTOPSIG(status)]);
+				pid, signame(WSTOPSIG(status)));
 
 		if (tcp->flags & TCB_STARTUP) {
 			/*
@@ -1509,7 +1509,7 @@
 			    && (qual_flags[WSTOPSIG(status)] & QUAL_SIGNAL)) {
 				printleader(tcp);
 				tprintf("--- %s (%s) ---",
-					signalent[WSTOPSIG(status)],
+					signame(WSTOPSIG(status)),
 					strsignal(WSTOPSIG(status)));
 				printtrailer(tcp);
 			}
diff --git a/syscall.c b/syscall.c
index 3d9ee95..70e516e 100644
--- a/syscall.c
+++ b/syscall.c
@@ -252,7 +252,7 @@
 	if (strncmp(s, "SIG", 3) == 0)
 		s += 3;
 	for (i = 0; i <= NSIG; i++) {
-		if (strcmp(s, signalent[i] + 3) == 0)
+		if (strcmp(s, signame(i) + 3) == 0)
 			return i;
 	}
 	return -1;