Kernel: Remove unnecessary raise syscall

This commit is contained in:
Bananymous 2023-12-06 13:00:45 +02:00
parent 336daa2cc5
commit cdcc36efde
5 changed files with 10 additions and 21 deletions

View File

@ -137,7 +137,6 @@ namespace Kernel
BAN::ErrorOr<long> sys_tty_ctrl(int fildes, int command, int flags); BAN::ErrorOr<long> sys_tty_ctrl(int fildes, int command, int flags);
BAN::ErrorOr<long> sys_signal(int, void (*)(int)); BAN::ErrorOr<long> sys_signal(int, void (*)(int));
BAN::ErrorOr<long> sys_raise(int signal);
static BAN::ErrorOr<long> sys_kill(pid_t pid, int signal); static BAN::ErrorOr<long> sys_kill(pid_t pid, int signal);
BAN::ErrorOr<long> sys_tcsetpgrp(int fd, pid_t pgid); BAN::ErrorOr<long> sys_tcsetpgrp(int fd, pid_t pgid);

View File

@ -468,7 +468,7 @@ namespace Kernel
if (!m_loadable_elf->is_address_space_free()) if (!m_loadable_elf->is_address_space_free())
{ {
dprintln("ELF has unloadable address space"); dprintln("ELF has unloadable address space");
MUST(sys_raise(SIGKILL)); MUST(sys_kill(pid(), SIGKILL));
} }
m_loadable_elf->reserve_address_space(); m_loadable_elf->reserve_address_space();
m_userspace_info.entry = m_loadable_elf->entry_point(); m_userspace_info.entry = m_loadable_elf->entry_point();
@ -1218,7 +1218,11 @@ namespace Kernel
return BAN::Error::from_errno(EINVAL); return BAN::Error::from_errno(EINVAL);
if (pid == Process::current().pid()) if (pid == Process::current().pid())
return Process::current().sys_raise(signal); {
CriticalScope _;
Process::current().m_signal_pending_mask |= 1 << signal;
return 0;
}
bool found = false; bool found = false;
for_each_process( for_each_process(
@ -1243,17 +1247,6 @@ namespace Kernel
return BAN::Error::from_errno(ESRCH); return BAN::Error::from_errno(ESRCH);
} }
BAN::ErrorOr<long> Process::sys_raise(int signal)
{
if (signal < _SIGMIN || signal > _SIGMAX)
return BAN::Error::from_errno(EINVAL);
ASSERT(this == &Process::current());
CriticalScope _;
Thread::current().handle_signal(signal);
return 0;
}
BAN::ErrorOr<long> Process::sys_tcsetpgrp(int fd, pid_t pgrp) BAN::ErrorOr<long> Process::sys_tcsetpgrp(int fd, pid_t pgrp)
{ {
LockGuard _(m_lock); LockGuard _(m_lock);
@ -1627,7 +1620,7 @@ namespace Kernel
unauthorized_access: unauthorized_access:
dwarnln("process {}, thread {} attempted to make an invalid pointer access", pid(), Thread::current().tid()); dwarnln("process {}, thread {} attempted to make an invalid pointer access", pid(), Thread::current().tid());
Debug::dump_stack_trace(); Debug::dump_stack_trace();
MUST(sys_raise(SIGSEGV)); MUST(sys_kill(pid(), SIGSEGV));
} }
} }

View File

@ -148,9 +148,6 @@ namespace Kernel
case SYS_DUP2: case SYS_DUP2:
ret = Process::current().sys_dup2((int)arg1, (int)arg2); ret = Process::current().sys_dup2((int)arg1, (int)arg2);
break; break;
case SYS_RAISE:
ret = Process::current().sys_raise((int)arg1);
break;
case SYS_KILL: case SYS_KILL:
ret = Process::current().sys_kill((pid_t)arg1, (int)arg2); ret = Process::current().sys_kill((pid_t)arg1, (int)arg2);
break; break;

View File

@ -38,7 +38,6 @@ __BEGIN_DECLS
#define SYS_PIPE 35 #define SYS_PIPE 35
#define SYS_DUP 36 #define SYS_DUP 36
#define SYS_DUP2 37 #define SYS_DUP2 37
#define SYS_RAISE 38
#define SYS_KILL 39 #define SYS_KILL 39
#define SYS_SIGNAL 40 #define SYS_SIGNAL 40
#define SYS_SIGNAL_DONE 41 #define SYS_SIGNAL_DONE 41

View File

@ -4,7 +4,8 @@
int raise(int sig) int raise(int sig)
{ {
return syscall(SYS_RAISE, sig); // FIXME: won't work after multithreaded
return kill(getpid(), sig);
} }
int kill(pid_t pid, int sig) int kill(pid_t pid, int sig)