forked from Bananymous/banan-os
Kernel: Change signal kernel API
return rsp and rip are now stored per thread
This commit is contained in:
@@ -806,18 +806,19 @@ namespace Kernel
|
||||
return 0;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_kill(pid_t pid, int signal, uintptr_t& return_rsp, uintptr_t& return_rip)
|
||||
BAN::ErrorOr<long> Process::sys_kill(pid_t pid, int signal)
|
||||
{
|
||||
if (pid <= 0)
|
||||
return BAN::Error::from_errno(ENOTSUP);
|
||||
if (signal != 0 && (signal < _SIGMIN || signal > _SIGMAX))
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
|
||||
if (pid == this->pid())
|
||||
return sys_raise(signal, return_rsp, return_rip);
|
||||
|
||||
if (pid == Process::current().pid())
|
||||
return Process::current().sys_raise(signal);
|
||||
|
||||
LockGuard process_guard(s_process_lock);
|
||||
CriticalScope _;
|
||||
|
||||
for (auto* process : s_processes)
|
||||
{
|
||||
if (process->pid() == pid)
|
||||
@@ -831,17 +832,24 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(ESRCH);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_raise(int signal, uintptr_t& return_rsp, uintptr_t& return_rip)
|
||||
BAN::ErrorOr<long> Process::sys_raise(int signal)
|
||||
{
|
||||
if (signal < _SIGMIN || signal > _SIGMAX)
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
ASSERT(m_threads.size() == 1);
|
||||
CriticalScope _;
|
||||
Thread::current().m_signal_queue.push(signal);
|
||||
Thread::current().handle_signal(signal, return_rsp, return_rip);
|
||||
Thread& current = Thread::current();
|
||||
current.m_signal_queue.push(signal);
|
||||
current.handle_next_signal();
|
||||
return 0;
|
||||
}
|
||||
|
||||
pid_t Process::foreground_pid()
|
||||
{
|
||||
ASSERT(s_foreground_pid);
|
||||
return s_foreground_pid;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_setuid(uid_t uid)
|
||||
{
|
||||
if (uid < 0 || uid >= 1'000'000'000)
|
||||
|
||||
Reference in New Issue
Block a user