diff --git a/src/context/switch.rs b/src/context/switch.rs index cdcc3d5f53..9119757145 100644 --- a/src/context/switch.rs +++ b/src/context/switch.rs @@ -211,6 +211,8 @@ pub fn switch() -> SwitchResult { next_context.syscall_debug_info.on_switch_to(); } + percpu.switch_internals.being_sigkilled.set(next_context.being_sigkilled); + unsafe { arch::switch_to(prev_context, next_context); } @@ -240,6 +242,8 @@ pub struct ContextSwitchPercpu { // The ID of the idle process idle_id: Cell, + + pub(crate) being_sigkilled: Cell, } impl ContextSwitchPercpu { pub fn context_id(&self) -> ContextId { diff --git a/src/syscall/mod.rs b/src/syscall/mod.rs index c0823142b7..f4a9b25460 100644 --- a/src/syscall/mod.rs +++ b/src/syscall/mod.rs @@ -4,7 +4,7 @@ extern crate syscall; -use syscall::{RwFlags, EINVAL}; +use syscall::{RwFlags, EINVAL, SIGKILL}; pub use self::syscall::{ data, error, flag, io, number, ptrace_event, EnvRegisters, FloatRegisters, IntRegisters, @@ -195,7 +195,7 @@ pub fn syscall( SYS_GETPGID => getpgid(ContextId::from(b)).map(ContextId::into), SYS_GETPPID => getppid().map(ContextId::into), - SYS_EXIT => exit((b & 0xFF) << 8), + SYS_EXIT => exit(b), SYS_KILL => kill(ContextId::from(b), c), SYS_WAITPID => waitpid( ContextId::from(b), @@ -244,7 +244,12 @@ pub fn syscall( #[cfg(feature = "syscall_debug")] debug_end([a, b, c, d, e, f], result); - PercpuBlock::current().inside_syscall.set(false); + let percpu = PercpuBlock::current(); + percpu.inside_syscall.set(false); + + if percpu.switch_internals.being_sigkilled.get() { + exit(SIGKILL); + } // errormux turns Result into -errno Error::mux(result) diff --git a/syscall b/syscall index a8dfcdf7df..f0483e3b33 160000 --- a/syscall +++ b/syscall @@ -1 +1 @@ -Subproject commit a8dfcdf7dfcc3fa13f39c6202d71b03d1bc91066 +Subproject commit f0483e3b3391b993e28af32788d3651e30e5805a