summaryrefslogtreecommitdiff
path: root/src/libc/signal.c
diff options
context:
space:
mode:
authordzwdz2023-08-14 18:51:07 +0200
committerdzwdz2023-08-14 18:51:07 +0200
commit642b5fb0007b64c77d186fcb018d571152ee1d47 (patch)
tree1c466461f3602d306be309a053edae558ef2568e /src/libc/signal.c
parent8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff)
reorganization: first steps
Diffstat (limited to 'src/libc/signal.c')
-rw-r--r--src/libc/signal.c100
1 files changed, 100 insertions, 0 deletions
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 <bits/panic.h>
+#include <signal.h>
+
+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");
+}