diff options
author | pk33 <pk33@email.com> | 2024-11-03 12:07:55 +0100 |
---|---|---|
committer | pk33 <pk33@email.com> | 2024-11-03 12:07:55 +0100 |
commit | 844a19f9bfe01286ca9974aff0e6d38693e05877 (patch) | |
tree | beca8efb8300fe3b6c78e9da26560cf674b57595 /src/system.c | |
parent | 23ab6c4e6483159b77af8b4edf95113887a300d7 (diff) | |
download | engine33-844a19f9bfe01286ca9974aff0e6d38693e05877.tar.gz |
cleanup code & term handlers
Diffstat (limited to 'src/system.c')
-rw-r--r-- | src/system.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/system.c b/src/system.c index cff4f54..9a9a80e 100644 --- a/src/system.c +++ b/src/system.c @@ -5,6 +5,7 @@ #include "stdio.h" #include "unistd.h" #include "string.h" +#include "signal.h" #include "types.h" @@ -20,7 +21,7 @@ err e33_ioctl( Size fd, unsigned long req, void *arg ) return ret; } -boolean strcomp( String s1, String s2 ) +boolean e33_strcmp( String s1, String s2 ) { while( (*s1 != '\0') && (*s2 != '\0') ) { @@ -32,3 +33,18 @@ boolean strcomp( String s1, String s2 ) return E33_TRUE; } +err e33_has_signal(Size signo) +{ + struct sigaction sact = {0}; + sigaction(signo, 0, &sact); + return sact.sa_handler != 0; +} + +err e33_set_signal(Size signo, void(*sig_handler)(int)) +{ + struct sigaction sact = {0}; + sact.sa_handler = sig_handler; + sigemptyset(&sact.sa_mask); + sact.sa_flags = SA_RESTART; + return sigaction(signo, &sact, NULL); +} |