feature: basic signal handling

This commit is contained in:
2021-11-11 13:46:36 +02:00
parent dacbea02d6
commit afc6ccc8dd
11 changed files with 261 additions and 18 deletions
+14
View File
@@ -10,9 +10,20 @@ pub mod os;
pub mod sys {
pub use syscall::calls::*;
pub use syscall::stat::*;
pub use syscall::signal::Signal;
pub use syscall::termios;
}
#[inline(never)]
extern "C" fn _signal_handler(arg: sys::Signal) -> ! {
trace!("Entered signal handler: arg={:?}", arg);
unsafe {
sys::sys_ex_sigreturn();
}
}
static mut SIGNAL_STACK: [u8; 4096] = [0; 4096];
#[link_section = ".text._start"]
#[no_mangle]
extern "C" fn _start(_arg: usize) -> ! {
@@ -20,6 +31,9 @@ extern "C" fn _start(_arg: usize) -> ! {
fn main() -> i32;
}
unsafe {
SIGNAL_STACK[0] = 1;
sys::sys_ex_signal(_signal_handler as usize, SIGNAL_STACK.as_ptr() as usize + 4096);
sys::sys_exit(main());
}
}