Skip to content

Commit

Permalink
Implement SA_RESETHAND_
Browse files Browse the repository at this point in the history
Fixes ctrl-c sometimes sending Node's signal handler into an infinite
loop. ish-app#90
  • Loading branch information
tbodt authored and Mnpn committed Oct 22, 2020
1 parent 3df9c8f commit 58d981e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ static void receive_signal(struct sighand *sighand, struct siginfo_ *info) {
printk("failed to install frame for %d at %#x\n", info->sig, sp);
deliver_signal(current, SIGSEGV_, SIGINFO_NIL);
}

if (action->flags & SA_RESETHAND_)
*action = (struct sigaction_) {.handler = SIG_DFL_};
}

void receive_signals() {
Expand Down Expand Up @@ -443,7 +446,9 @@ dword_t sys_rt_sigaction(dword_t signum, addr_t action_addr, addr_t oldaction_ad
if (action_addr != 0)
if (user_get(action_addr, action))
return _EFAULT;
STRACE("rt_sigaction(%d, 0x%x, 0x%x, %d)", signum, action_addr, oldaction_addr, sigset_size);
STRACE("rt_sigaction(%d, %#x {handler=%#x, flags=%#x, restorer=%#x, mask=%#llx}, 0x%x, %d)", signum,
action_addr, action.handler, action.flags, action.restorer,
(unsigned long long) action.mask, oldaction_addr, sigset_size);

int err = do_sigaction(signum,
action_addr ? &action : NULL,
Expand Down
1 change: 1 addition & 0 deletions kernel/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef qword_t sigset_t_;

#define SA_SIGINFO_ 4
#define SA_NODEFER_ 0x40000000
#define SA_RESETHAND_ 0x80000000

struct sigaction_ {
addr_t handler;
Expand Down

0 comments on commit 58d981e

Please sign in to comment.