Fix stop signal by switching context after stopping

This commit is contained in:
Jeremy Soller
2018-01-04 09:03:41 -07:00
parent 49d5c33928
commit 9313909fe9
2 changed files with 4 additions and 3 deletions

View File

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

View File

@@ -986,13 +986,13 @@ pub fn kill(pid: ContextId, sig: usize) -> Result<usize> {
|| 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