Skip to content

Commit

Permalink
Merge pull request #178 from lhw2002426/signal
Browse files Browse the repository at this point in the history
detach signal handle from sigaction
  • Loading branch information
ken4647 authored Feb 19, 2025
2 parents 62068cd + 6fb4cef commit 480358c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/ruxruntime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ fn init_interrupt() {
{
Signal::signal(signum as i8, false);
Signal::sigaction(signum as u8, None, None);
Signal::signal_handle(signum as u8);
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions modules/ruxtask/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl TrapHandler for SignalHandler {
{
Signal::signal(signum as i8, false);
Signal::sigaction(signum as u8, None, None);
Signal::signal_handle(signum as u8);
}
}
}
Expand Down Expand Up @@ -155,6 +156,20 @@ impl Signal {
}
}
}
/// Handle signal for the current process
/// signum: Signal number to handle
/// When the registered sa_handler for the specified signal is None, logs an error message
pub fn signal_handle(signum: u8) {
let binding = current();
let mut current_signal_if = binding.signal_if.lock();
if let Some(handler) = current_signal_if.sigaction[signum as usize].sa_handler {
unsafe {
handler(signum as c_int);
}
} else {
error!("no sigaction !");
}
}
/// Set timer
/// which: timer type
/// new_value: new timer value
Expand Down

0 comments on commit 480358c

Please sign in to comment.