Implement signal() via sigaction() and get rid of sys$signal().

This commit is contained in:
Andreas Kling 2018-11-28 22:27:32 +01:00
parent d90104f9e0
commit 464a16afa2
Notes: sideshowbarker 2024-07-19 16:09:31 +09:00
5 changed files with 9 additions and 19 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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:

View File

@ -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) \

View File

@ -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)