From 9313909fe9547970807424e99cbafef4e0ead285 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 4 Jan 2018 09:03:41 -0700 Subject: [PATCH] Fix stop signal by switching context after stopping --- src/context/signal.rs | 5 +++-- src/syscall/process.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/context/signal.rs b/src/context/signal.rs index d2d9043..f51deb4 100644 --- a/src/context/signal.rs +++ b/src/context/signal.rs @@ -1,7 +1,7 @@ use alloc::arc::Arc; use core::mem; -use context::{contexts, Status}; +use context::{contexts, switch, Status}; use start::usermode; use syscall; use syscall::flag::{SIG_DFL, SIG_IGN, SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU}; @@ -16,7 +16,6 @@ pub extern "C" fn signal_handler(sig: usize) { }; let handler = action.sa_handler as usize; - println!("Handler {}: {:X}", sig, handler); if handler == SIG_DFL { match sig { SIGCHLD => { @@ -71,6 +70,8 @@ pub extern "C" fn signal_handler(sig: usize) { println!("{}: {} not found for stop", pid.into(), ppid.into()); } } + + unsafe { switch() }; }, _ => { println!("Exit {}", sig); diff --git a/src/syscall/process.rs b/src/syscall/process.rs index 62672bc..b627d7b 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -986,13 +986,13 @@ pub fn kill(pid: ContextId, sig: usize) -> Result { || euid == context.ruid || ruid == context.ruid { + context.pending.push_back(sig as u8); // Convert stopped processes to blocked if sending SIGCONT if sig == SIGCONT { if let context::Status::Stopped(_sig) = context.status { context.status = context::Status::Blocked; } } - context.pending.push_back(sig as u8); true } else { false