hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 97a1fb41676283f38dc4890b3bd85156e06af1fe
parent 7894dc4ab32dd4ace7e92686e2511c590816a089
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 16 Dec 2022 13:43:25 +0100

unix::signal: add signame

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Munix/signal/+linux.ha | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+), 0 deletions(-)

diff --git a/unix/signal/+linux.ha b/unix/signal/+linux.ha @@ -283,3 +283,71 @@ export def SIGPOLL: signal = rt::SIGPOLL; export def SIGPWR: signal = rt::SIGPWR; // Bad system call. export def SIGSYS: signal = rt::SIGSYS; + +// Returns the human friendly name of a given signal. +export fn signame(sig: signal) const str = { + switch (sig) { + case SIGHUP => + return "SIGHUP"; + case SIGINT => + return "SIGINT"; + case SIGQUIT => + return "SIGQUIT"; + case SIGILL => + return "SIGILL"; + case SIGTRAP => + return "SIGTRAP"; + case SIGABRT => + return "SIGABRT"; + case SIGBUS => + return "SIGBUS"; + case SIGFPE => + return "SIGFPE"; + case SIGKILL => + return "SIGKILL"; + case SIGUSR1 => + return "SIGUSR1"; + case SIGSEGV => + return "SIGSEGV"; + case SIGUSR2 => + return "SIGUSR2"; + case SIGPIPE => + return "SIGPIPE"; + case SIGALRM => + return "SIGALRM"; + case SIGTERM => + return "SIGTERM"; + case SIGCHLD => + return "SIGCHLD"; + case SIGCONT => + return "SIGCONT"; + case SIGSTOP => + return "SIGSTOP"; + case SIGTSTP => + return "SIGTSTP"; + case SIGTTIN => + return "SIGTTIN"; + case SIGTTOU => + return "SIGTTOU"; + case SIGURG => + return "SIGURG"; + case SIGXCPU => + return "SIGXCPU"; + case SIGXFSZ => + return "SIGXFSZ"; + case SIGVTALRM => + return "SIGVTALRM"; + case SIGPROF => + return "SIGPROF"; + case SIGWINCH => + return "SIGWINCH"; + case SIGIO => + return "SIGIO"; + case SIGPOLL => + return "SIGPOLL"; + case SIGPWR => + return "SIGPWR"; + case SIGSYS => + return "SIGSYS"; + }; +};