Support signal mechanism for ch8(only works on signal-thread apps)
This commit is contained in:
parent
59f13cb536
commit
26bc01f3bc
17 changed files with 235 additions and 17 deletions
|
@ -1,8 +1,8 @@
|
|||
use crate::fs::{open_file, OpenFlags};
|
||||
use crate::mm::{translated_ref, translated_refmut, translated_str};
|
||||
use crate::task::{
|
||||
current_process, current_task, current_user_token, exit_current_and_run_next,
|
||||
suspend_current_and_run_next,
|
||||
current_process, current_task, current_user_token, exit_current_and_run_next, pid2process,
|
||||
suspend_current_and_run_next, SignalFlags,
|
||||
};
|
||||
use crate::timer::get_time_ms;
|
||||
use alloc::string::String;
|
||||
|
@ -103,3 +103,16 @@ pub fn sys_waitpid(pid: isize, exit_code_ptr: *mut i32) -> isize {
|
|||
}
|
||||
// ---- release current PCB automatically
|
||||
}
|
||||
|
||||
pub fn sys_kill(pid: usize, signal: u32) -> isize {
|
||||
if let Some(process) = pid2process(pid) {
|
||||
if let Some(flag) = SignalFlags::from_bits(signal) {
|
||||
process.inner_exclusive_access().signals |= flag;
|
||||
0
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue