Kernel/LibC: Add bareboness signals

You can now call raise() to raise a signal. Signal handlers are
not yet supported, but the handling works :)
This commit is contained in:
Bananymous
2023-07-21 15:45:02 +03:00
parent a1db032ba9
commit c2cf98e32f
14 changed files with 126 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ set(LIBC_SOURCES
fcntl.cpp
printf_impl.cpp
pwd.cpp
signal.cpp
stdio.cpp
stdlib.cpp
string.cpp

View File

@@ -74,6 +74,9 @@ struct sigevent
#define SIGRTMIN 29
#define SIGRTMAX (SIGRTMIN+32)
#define _SIGMIN SIGABRT
#define _SIGMAX SIGRTMAX
#define SIG_BLOCK 1
#define SIG_UNBLOCK 2
#define SIG_SETMASK 3

View File

@@ -41,6 +41,7 @@ __BEGIN_DECLS
#define SYS_CLOCK_GETTIME 34
#define SYS_PIPE 35
#define SYS_DUP2 36
#define SYS_RAISE 37
__END_DECLS

8
libc/signal.cpp Normal file
View File

@@ -0,0 +1,8 @@
#include <signal.h>
#include <sys/syscall.h>
#include <unistd.h>
int raise(int sig)
{
return syscall(SYS_RAISE, sig);
}

View File

@@ -266,6 +266,12 @@ long syscall(long syscall, ...)
ret = Kernel::syscall(SYS_DUP2, fildes, fildes2);
break;
}
case SYS_RAISE:
{
int signal = va_arg(args, int);
ret = Kernel::syscall(SYS_RAISE, signal);
break;
}
default:
puts("LibC: Unhandeled syscall");
ret = -ENOSYS;