diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
| commit | fc00c656c96528112d05cf0edf8631bd5eaea446 (patch) | |
| tree | a6e0e6c588191a8bd1c64afc3b7a258e3e66c236 /lib/libc/signal/sig2str.c | |
Add build system scaffolding and libc headers
Diffstat (limited to 'lib/libc/signal/sig2str.c')
| -rw-r--r-- | lib/libc/signal/sig2str.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/libc/signal/sig2str.c b/lib/libc/signal/sig2str.c new file mode 100644 index 00000000..209cb4c3 --- /dev/null +++ b/lib/libc/signal/sig2str.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <string.h> +#include <asm-generic/signal.h> +#include <__signal.h> + +int sig2str(int signum, char *str) +{ + if (signum >= SIGHUP && signum <= SIGSYS) { + strcpy(str, __sys_signame[signum - SIGHUP]); + return 0; + } + + if (signum == SIGRTMIN) { + strcpy(str, "SIGRTMIN"); + return 0; + } + + if (signum == SIGRTMAX) { + strcpy(str, "RTMAX"); + return 0; + } + + if (signum > SIGRTMIN && signum < SIGRTMAX) { + if (signum - SIGRTMIN <= SIGRTMAX - signum) { + sprintf(str, "RTMIN+%d", signum - SIGRTMIN); + } else { + sprintf(str, "RTMAX-%d", SIGRTMAX - signum); + } + return 0; + } + + return -1; +} |
