Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#81] Add better log error output for signal handler failure #91

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions iceoryx2-bb/posix/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use crate::{
use enum_iterator::{all, Sequence};
use iceoryx2_bb_elementary::enum_gen;
use iceoryx2_bb_log::{fail, fatal_panic};
use iceoryx2_pal_posix::posix::Struct;
use iceoryx2_pal_posix::posix::{Errno, Struct};
use iceoryx2_pal_posix::*;
use lazy_static::lazy_static;
use std::sync::atomic::{AtomicUsize, Ordering};
Expand Down Expand Up @@ -184,6 +184,7 @@ tiny_fn! {
pub struct SignalCallback = Fn(signal: FetchableSignal);
}

#[derive(Debug)]
struct SignalDetail {
signal: FetchableSignal,
state: posix::sigaction_t,
Expand Down Expand Up @@ -509,10 +510,13 @@ impl SignalHandler {
};
let mut previous_action = posix::sigaction_t::new();

if unsafe { posix::sigaction(details.signal as i32, &adjusted_state, &mut previous_action) }
!= 0
{
fatal_panic!(from self, "This should never happen! Unable to register raw signal since sigaction was called with invalid parameters.");
let sigaction_return = unsafe {
posix::sigaction(details.signal as i32, &adjusted_state, &mut previous_action)
};

if sigaction_return != 0 {
fatal_panic!(from self, "This should never happen! posix::sigaction returned {}. Unable to register raw signal since sigaction was called with invalid parameters: {:?} which lead to error: {:?}.",
sigaction_return, details, Errno::get());
}

previous_action
Expand Down
4 changes: 2 additions & 2 deletions iceoryx2-pal/posix/src/windows/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub type ushort = u16;
pub type ulong = u64;
pub type void = core::ffi::c_void;

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub struct sigset_t {}
impl Struct for sigset_t {}

Expand Down Expand Up @@ -221,7 +221,7 @@ pub struct sched_param {
}
impl Struct for sched_param {}

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct sigaction_t {
pub iox2_sa_handler: sighandler_t,
Expand Down