Skip to content

Commit

Permalink
[#81] Add better log error output for signal handler failure
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Jan 16, 2024
1 parent 891ae9b commit 358a814
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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
2 changes: 1 addition & 1 deletion iceoryx2-pal/posix/src/windows/types.rs
Original file line number Diff line number Diff line change
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

0 comments on commit 358a814

Please sign in to comment.