forked from Bananymous/banan-os
Kernel/LibC: add SYS_SIGNAL/signal()
This commit is contained in:
parent
2149cec29f
commit
7391d91317
|
@ -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;
|
||||
|
|
|
@ -43,6 +43,7 @@ __BEGIN_DECLS
|
|||
#define SYS_DUP2 36
|
||||
#define SYS_RAISE 37
|
||||
#define SYS_KILL 38
|
||||
#define SYS_SIGNAL 39
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -10,4 +10,10 @@ int raise(int sig)
|
|||
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;
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue