Kernel/LibC: add SYS_SIGNAL/signal()

This commit is contained in:
Bananymous 2023-07-21 20:08:13 +03:00
parent 2149cec29f
commit 7391d91317
4 changed files with 17 additions and 0 deletions

View File

@ -146,6 +146,9 @@ namespace Kernel
case SYS_KILL:
ret = Process::current().sys_kill((pid_t)arg1, (int)arg2, interrupt_stack.rsp, interrupt_stack.rip);
break;
case SYS_SIGNAL:
ret = Process::current().sys_signal((int)arg1, (void (*)(int))arg2);
break;
default:
dwarnln("Unknown syscall {}", syscall);
break;

View File

@ -43,6 +43,7 @@ __BEGIN_DECLS
#define SYS_DUP2 36
#define SYS_RAISE 37
#define SYS_KILL 38
#define SYS_SIGNAL 39
__END_DECLS

View File

@ -11,3 +11,9 @@ int kill(pid_t pid, int sig)
{
return syscall(SYS_KILL, pid, sig);
}
void (*signal(int sig, void (*func)(int)))(int)
{
long ret = syscall(SYS_SIGNAL, sig, func);
return (void (*)(int))ret;
}

View File

@ -279,6 +279,13 @@ long syscall(long syscall, ...)
ret = Kernel::syscall(SYS_KILL, pid, signal);
break;
}
case SYS_SIGNAL:
{
int signal = va_arg(args, int);
void (*handler)(int) = va_arg(args, void(*)(int));
ret = Kernel::syscall(SYS_SIGNAL, signal, (uintptr_t)handler);
break;
}
default:
puts("LibC: Unhandeled syscall");
ret = -ENOSYS;