diff --git a/kernel/include/kernel/Process.h b/kernel/include/kernel/Process.h index e0d4d180da..7f1e882f72 100644 --- a/kernel/include/kernel/Process.h +++ b/kernel/include/kernel/Process.h @@ -137,7 +137,6 @@ namespace Kernel BAN::ErrorOr sys_tty_ctrl(int fildes, int command, int flags); BAN::ErrorOr sys_signal(int, void (*)(int)); - BAN::ErrorOr sys_raise(int signal); static BAN::ErrorOr sys_kill(pid_t pid, int signal); BAN::ErrorOr sys_tcsetpgrp(int fd, pid_t pgid); diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 7c89e4730d..82f93ede0e 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -468,7 +468,7 @@ namespace Kernel if (!m_loadable_elf->is_address_space_free()) { dprintln("ELF has unloadable address space"); - MUST(sys_raise(SIGKILL)); + MUST(sys_kill(pid(), SIGKILL)); } m_loadable_elf->reserve_address_space(); m_userspace_info.entry = m_loadable_elf->entry_point(); @@ -1218,8 +1218,12 @@ namespace Kernel return BAN::Error::from_errno(EINVAL); 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; for_each_process( [&](Process& process) @@ -1243,17 +1247,6 @@ namespace Kernel return BAN::Error::from_errno(ESRCH); } - BAN::ErrorOr 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 Process::sys_tcsetpgrp(int fd, pid_t pgrp) { LockGuard _(m_lock); @@ -1627,7 +1620,7 @@ namespace Kernel unauthorized_access: dwarnln("process {}, thread {} attempted to make an invalid pointer access", pid(), Thread::current().tid()); Debug::dump_stack_trace(); - MUST(sys_raise(SIGSEGV)); + MUST(sys_kill(pid(), SIGSEGV)); } } \ No newline at end of file diff --git a/kernel/kernel/Syscall.cpp b/kernel/kernel/Syscall.cpp index ec8a953ec9..030a74f71c 100644 --- a/kernel/kernel/Syscall.cpp +++ b/kernel/kernel/Syscall.cpp @@ -148,9 +148,6 @@ namespace Kernel case SYS_DUP2: ret = Process::current().sys_dup2((int)arg1, (int)arg2); break; - case SYS_RAISE: - ret = Process::current().sys_raise((int)arg1); - break; case SYS_KILL: ret = Process::current().sys_kill((pid_t)arg1, (int)arg2); break; diff --git a/libc/include/sys/syscall.h b/libc/include/sys/syscall.h index 7c568950c6..e9e93a793f 100644 --- a/libc/include/sys/syscall.h +++ b/libc/include/sys/syscall.h @@ -38,7 +38,6 @@ __BEGIN_DECLS #define SYS_PIPE 35 #define SYS_DUP 36 #define SYS_DUP2 37 -#define SYS_RAISE 38 #define SYS_KILL 39 #define SYS_SIGNAL 40 #define SYS_SIGNAL_DONE 41 diff --git a/libc/signal.cpp b/libc/signal.cpp index 39f8694367..0285e3fcd9 100644 --- a/libc/signal.cpp +++ b/libc/signal.cpp @@ -4,7 +4,8 @@ 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)