pub(crate) unsafe fn install_abort_handler() -> Result<libc::sighandler_t, std::io::Error> {
let old_handler = libc::signal(libc::SIGABRT, signal_handler as usize);
if old_handler != usize::MAX {
Ok(old_handler)
} else {
Err(std::io::Error::last_os_error())
}
}
#[inline]
pub(crate) unsafe fn restore_abort_handler(handler: libc::sighandler_t) {
libc::signal(libc::SIGABRT, handler);
}
unsafe extern "C" fn signal_handler(signal: i32, _subcode: i32) {
assert_eq!(signal, libc::SIGABRT);
super::state::simulate_exception(Some(super::ExceptionCode::Abort as u32));
}