From 844a19f9bfe01286ca9974aff0e6d38693e05877 Mon Sep 17 00:00:00 2001 From: pk33 Date: Sun, 3 Nov 2024 12:07:55 +0100 Subject: cleanup code & term handlers --- src/system.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/system.c') 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); +} -- cgit v1.2.3