diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 50686b0ab7c..94879feb834 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1660,15 +1660,6 @@ int Process::sys$dup2(int old_fd, int new_fd) return new_fd; } -Unix::sighandler_t Process::sys$signal(int signum, Unix::sighandler_t handler) -{ - // FIXME: Fail with -EINVAL if attepmting to catch or ignore SIGKILL or SIGSTOP. - if (signum < 1 || signum >= 32) - return (Unix::sighandler_t)-EINVAL; - dbgprintf("sys$signal: %d => L%x\n", signum, handler); - return nullptr; -} - int Process::sys$sigprocmask(int how, const Unix::sigset_t* set, Unix::sigset_t* old_set) { if (old_set) { diff --git a/Kernel/Process.h b/Kernel/Process.h index 029a1431b72..f64705765e7 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -154,7 +154,6 @@ public: int sys$ttyname_r(int fd, char*, size_t); pid_t sys$fork(RegisterDump&); int sys$execve(const char* filename, const char** argv, const char** envp); - Unix::sighandler_t sys$signal(int signum, Unix::sighandler_t); int sys$isatty(int fd); int sys$getdtablesize(); int sys$dup(int oldfd); diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 945a7915d69..f1ebe6a88b4 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -133,8 +133,6 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2, return current->sys$geteuid(); case Syscall::SC_getegid: return current->sys$getegid(); - case Syscall::SC_signal: - return (dword)current->sys$signal((int)arg1, (Unix::sighandler_t)arg2); case Syscall::SC_isatty: return current->sys$isatty((int)arg1); case Syscall::SC_getdtablesize: diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 0349b609deb..18fdf5d9d79 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -41,7 +41,6 @@ __ENUMERATE_SYSCALL(execve) \ __ENUMERATE_SYSCALL(geteuid) \ __ENUMERATE_SYSCALL(getegid) \ - __ENUMERATE_SYSCALL(signal) \ __ENUMERATE_SYSCALL(isatty) \ __ENUMERATE_SYSCALL(getdtablesize) \ __ENUMERATE_SYSCALL(dup) \ diff --git a/LibC/signal.cpp b/LibC/signal.cpp index a59cb83c5b1..215ac2a56c9 100644 --- a/LibC/signal.cpp +++ b/LibC/signal.cpp @@ -20,13 +20,16 @@ int killpg(int pgrp, int sig) sighandler_t signal(int signum, sighandler_t handler) { - sighandler_t old_handler = (sighandler_t)Syscall::invoke(Syscall::SC_signal, (dword)signum, (dword)handler); - if (old_handler == SIG_ERR) { - errno = EINVAL; + struct sigaction new_act; + struct sigaction old_act; + new_act.sa_handler = handler; + new_act.sa_flags = 0; + new_act.sa_mask = 0; + new_act.sa_restorer = nullptr; + int rc = sigaction(signum, &new_act, &old_act); + if (rc < 0) return SIG_ERR; - } - errno = 0; - return old_handler; + return old_act.sa_handler; } int sigaction(int signum, const struct sigaction* act, struct sigaction* old_act)