mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-27 11:23:25 +00:00
Exit when handle_user_signal fail
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
e75b6320ad
commit
5df8d59563
@ -17,6 +17,7 @@ use core::{mem, sync::atomic::Ordering};
|
|||||||
|
|
||||||
use align_ext::AlignExt;
|
use align_ext::AlignExt;
|
||||||
use c_types::{siginfo_t, ucontext_t};
|
use c_types::{siginfo_t, ucontext_t};
|
||||||
|
use constants::SIGKILL;
|
||||||
pub use events::{SigEvents, SigEventsFilter};
|
pub use events::{SigEvents, SigEventsFilter};
|
||||||
use ostd::{cpu::UserContext, user::UserContextApi};
|
use ostd::{cpu::UserContext, user::UserContextApi};
|
||||||
pub use pause::{with_signal_blocked, Pause};
|
pub use pause::{with_signal_blocked, Pause};
|
||||||
@ -46,7 +47,7 @@ pub fn handle_pending_signal(
|
|||||||
user_ctx: &mut UserContext,
|
user_ctx: &mut UserContext,
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
syscall_number: Option<usize>,
|
syscall_number: Option<usize>,
|
||||||
) -> Result<()> {
|
) {
|
||||||
// We first deal with signal in current thread, then signal in current process.
|
// We first deal with signal in current thread, then signal in current process.
|
||||||
let posix_thread = ctx.posix_thread;
|
let posix_thread = ctx.posix_thread;
|
||||||
let signal = {
|
let signal = {
|
||||||
@ -54,7 +55,7 @@ pub fn handle_pending_signal(
|
|||||||
if let Some(signal) = posix_thread.dequeue_signal(&sig_mask) {
|
if let Some(signal) = posix_thread.dequeue_signal(&sig_mask) {
|
||||||
signal
|
signal
|
||||||
} else {
|
} else {
|
||||||
return Ok(());
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,8 +94,7 @@ pub fn handle_pending_signal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop(sig_dispositions);
|
drop(sig_dispositions);
|
||||||
|
if let Err(e) = handle_user_signal(
|
||||||
handle_user_signal(
|
|
||||||
ctx,
|
ctx,
|
||||||
sig_num,
|
sig_num,
|
||||||
handler_addr,
|
handler_addr,
|
||||||
@ -103,7 +103,10 @@ pub fn handle_pending_signal(
|
|||||||
mask,
|
mask,
|
||||||
user_ctx,
|
user_ctx,
|
||||||
signal.to_info(),
|
signal.to_info(),
|
||||||
)?
|
) {
|
||||||
|
debug!("Failed to handle user signal: {:?}", e);
|
||||||
|
do_exit_group(TermStatus::Killed(SIGKILL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SigAction::Dfl => {
|
SigAction::Dfl => {
|
||||||
drop(sig_dispositions);
|
drop(sig_dispositions);
|
||||||
@ -130,7 +133,6 @@ pub fn handle_pending_signal(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
@ -87,12 +87,12 @@ pub fn create_new_user_task(
|
|||||||
if current_thread.is_exited() {
|
if current_thread.is_exited() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
handle_pending_signal(user_ctx, &ctx, syscall_number).unwrap();
|
handle_pending_signal(user_ctx, &ctx, syscall_number);
|
||||||
// If current is suspended, wait for a signal to wake up self
|
// If current is suspended, wait for a signal to wake up self
|
||||||
while current_thread.is_stopped() {
|
while current_thread.is_stopped() {
|
||||||
Thread::yield_now();
|
Thread::yield_now();
|
||||||
debug!("{} is suspended.", current_posix_thread.tid());
|
debug!("{} is suspended.", current_posix_thread.tid());
|
||||||
handle_pending_signal(user_ctx, &ctx, None).unwrap();
|
handle_pending_signal(user_ctx, &ctx, None);
|
||||||
}
|
}
|
||||||
if current_thread.is_exited() {
|
if current_thread.is_exited() {
|
||||||
debug!("exit due to signal");
|
debug!("exit due to signal");
|
||||||
|
Reference in New Issue
Block a user