From 03a8357e84a9a7c478d787c4705dddf70dc99f7d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 7 Nov 2018 21:19:47 +0100 Subject: Implement sending signals to blocked-in-kernel processes. This is dirty but pretty cool! If we have a pending, unmasked signal for a process that's blocked inside the kernel, we set up alternate stacks for that process and unblock it to execute the signal handler. A slightly different return trampoline is used here: since we need to get back into the kernel, a dedicated syscall is used (sys$sigreturn.) This restores the TSS contents of the process to the state it was in while we were originally blocking in the kernel. NOTE: There's currently only one "kernel resume TSS" so signal nesting definitely won't work. --- Kernel/Syscall.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Kernel/Syscall.cpp') diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index a6695c377f..3a418edfa4 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -54,7 +54,7 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2, Console::the().putChar(arg1 & 0xff); break; case Syscall::SC_sleep: - return current->sys$sleep(arg1); + return current->sys$sleep((unsigned)arg1); case Syscall::SC_gettimeofday: return current->sys$gettimeofday((timeval*)arg1); case Syscall::SC_spawn: @@ -156,6 +156,10 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2, return current->sys$getgroups((int)arg1, (gid_t*)arg2); case Syscall::SC_setgroups: return current->sys$setgroups((size_t)arg1, (const gid_t*)arg2); + case Syscall::SC_sigreturn: + current->sys$sigreturn(); + ASSERT_NOT_REACHED(); + return 0; default: kprintf("<%u> int0x80: Unknown function %x requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3); break; -- cgit v1.2.3