summaryrefslogtreecommitdiff
path: root/kernel/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index 8c33fdf..86fae41 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1,13 +1,20 @@
#include <errno.h>
#include <kernel/con.h>
#include <kernel/sched.h>
+#include <signal.h>
#include <stdint.h>
+#include <sys/types.h>
#include <time.h>
#include <unistd.h>
extern uint32_t ticks;
int sys_puts(char *s) {
+ uint32_t sigs = 5;
+ printk("[kernel] Setting signals %01x for PID 0x%04x\n", sigs, ctask->pid);
+ ctask->signal |= sigs;
+
+ printk("[%04x] ", ctask->pid);
return printk(s);
}
@@ -27,6 +34,20 @@ void *sys_getpdir(void) {
return (void*) pdir;
}
+void *sys_signal(int sig, void (*func)(int)) {
+ if(sig < 0 || sig >= NRSIG)
+ return NULL;
+
+ /* SIGKILL and SIGSTOP cannot be caught */
+ if(sig == SIGKILL || sig == SIGSTOP)
+ return NULL;
+
+ printk("Task %x registered new signal handler 0x%08x for signal %01x\n", ctask->pid, (uint32_t) func, sig);
+ ctask->sig_handlers[sig] = func;
+
+ return func;
+}
+
int sys_dummy(void) {
return -ENOSYS;
}