From 642b5fb0007b64c77d186fcb018d571152ee1d47 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 14 Aug 2023 18:51:07 +0200 Subject: reorganization: first steps --- src/libc/signal.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/libc/signal.c (limited to 'src/libc/signal.c') diff --git a/src/libc/signal.c b/src/libc/signal.c new file mode 100644 index 0000000..3200263 --- /dev/null +++ b/src/libc/signal.c @@ -0,0 +1,100 @@ +#include +#include + +const char *const sys_siglist[] = { + NULL, + "SIGHUP", /* 1 */ + "SIGINT", /* 2 */ + "SIGQUIT", /* 3 */ + "SIGILL", /* 4 */ + "SIGTRAP", /* 5 */ + "SIGABRT", /* 6 */ + "SIGFPE", /* 8 */ + "SIGKILL", /* 9 */ + "SIGSEGV", /* 11 */ + "SIGPIPE", /* 13 */ + "SIGALRM", /* 14 */ + "SIGTERM", /* 15 */ + "SIGCONT", /* 16 */ + "SIGPIPE", /* 17 */ + "SIGTSTP", /* 18 */ + "SIGTTIN", /* 19 */ + "SIGTTOU", /* 20 */ + "SIGWINCH", /* 21 */ + "SIGCHLD", /* 22 */ +}; + +static struct sigaction sigaction_default = {}; +static struct sigaction *sigaction_current[] = { + NULL, + &sigaction_default, /* 1 */ + &sigaction_default, /* 2 */ + &sigaction_default, /* 3 */ + &sigaction_default, /* 4 */ + &sigaction_default, /* 5 */ + &sigaction_default, /* 6 */ + &sigaction_default, /* 8 */ + &sigaction_default, /* 9 */ + &sigaction_default, /* 11 */ + &sigaction_default, /* 13 */ + &sigaction_default, /* 14 */ + &sigaction_default, /* 15 */ + &sigaction_default, /* 16 */ + &sigaction_default, /* 17 */ + &sigaction_default, /* 18 */ + &sigaction_default, /* 19 */ + &sigaction_default, /* 20 */ + &sigaction_default, /* 21 */ + &sigaction_default, /* 22 */ +}; + +int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact) { + const int siglen = sizeof(sigaction_current) / sizeof(sigaction_current[0]); + if (sig >= siglen) { + return errno = EINVAL, -1; + } + if (oldact) { + oldact = sigaction_current[sig]; + } + if (act) { + if (sig == SIGKILL) { + return errno = EINVAL, -1; + } + sigaction_current[sig] = (void*)act; + } + return 0; +} + +int sigemptyset(sigset_t *set) { + (void)set; + return 0; +} + +int sigfillset(sigset_t *set) { + (void)set; + return 0; +} + +int sigprocmask(int how, const sigset_t *set, const sigset_t *oldset) { + return 0; +} + +int sigsuspend(const sigset_t *mask) { + (void)mask; + __libc_panic("unimplemented"); +} + +int signal(int sig, void (*func)(int)) { + (void)sig; (void)func; + return errno = ENOSYS, SIG_ERR; +} + +int kill(pid_t pid, int sig) { + (void)pid; (void)sig; + __libc_panic("unimplemented"); +} + +int raise(int sig) { + (void)sig; + __libc_panic("unimplemented"); +} -- cgit v1.2.3