aboutsummaryrefslogtreecommitdiffstats
path: root/consts.c
diff options
context:
space:
mode:
Diffstat (limited to 'consts.c')
-rw-r--r--consts.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/consts.c b/consts.c
index 567a6e7..4e68230 100644
--- a/consts.c
+++ b/consts.c
@@ -26,3 +26,32 @@ get_errno_name(int err)
sprintf(buf, "%i", err);
return buf;
}
+
+
+const char *
+get_signum_name(int sig)
+{
+ static char buf[3 * sizeof(sig) + 2];
+ int above_low, below_high;
+
+#define X(N) if (sig == N) return #N;
+ LIST_SIGNUMS(X)
+#undef X
+
+ if (__SIGRTMIN <= sig && sig <= __SIGRTMAX) {
+ above_low = sig - __SIGRTMIN;
+ below_high = __SIGRTMAX - sig;
+ if (!above_low)
+ return "__SIGRTMIN";
+ if (!below_high)
+ return "__SIGRTMAX";
+ if (above_low <= below_high)
+ sprintf(buf, "__SIGRTMIN+%i", above_low);
+ else
+ sprintf(buf, "__SIGRTMAX-%i", below_high);
+ return buf;
+ }
+
+ sprintf(buf, "%i", sig);
+ return buf;
+}