forked from Bananymous/banan-os
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:
@@ -14,6 +14,9 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
extern "C" void signal_trampoline();
|
||||
extern "C" void test_signal();
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
@@ -788,6 +791,27 @@ namespace Kernel
|
||||
return 0;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_raise(int signal, uintptr_t& return_rsp, uintptr_t& return_rip)
|
||||
{
|
||||
if (signal < _SIGMIN || signal > _SIGMAX)
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
|
||||
ASSERT(&Process::current() == this);
|
||||
|
||||
LockGuard lock_guard(m_lock);
|
||||
asm volatile("cli");
|
||||
|
||||
uintptr_t* return_rsp_ptr = (uintptr_t*)return_rsp;
|
||||
*--return_rsp_ptr = return_rip;
|
||||
*--return_rsp_ptr = signal;
|
||||
*--return_rsp_ptr = (uintptr_t)test_signal;
|
||||
|
||||
return_rsp = (uintptr_t)return_rsp_ptr;
|
||||
return_rip = (uintptr_t)signal_trampoline;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_setuid(uid_t uid)
|
||||
{
|
||||
if (uid < 0 || uid >= 1'000'000'000)
|
||||
|
||||
Reference in New Issue
Block a user