diff --git a/include/Timer.hpp b/include/Timer.hpp index 9991a91..3945d3b 100644 --- a/include/Timer.hpp +++ b/include/Timer.hpp @@ -41,7 +41,6 @@ private: Timer& operator=( const Timer& ); int m_signal; - struct sigaction m_sigAction; timer_t m_timerId; bool m_periodic; bool m_running; diff --git a/src/Timer.cpp b/src/Timer.cpp index 8768bae..0129eed 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -3,31 +3,10 @@ #include "Common.hpp" #include // sigset_t -#include // timer_t -#include // strerror - - -/// @note not used now, all signals are caught by sigwaitinfo -// static void sigHandler(int sig, siginfo_t *si, void *uc) -// { -// TRACE_STATIC; -// } - - -struct sigaction& sigActionInit( struct sigaction &sigAct, const int signal ) -{ - sigAct.sa_flags = SA_SIGINFO; -// sigAct.sa_sigaction = sigHandler; - sigemptyset( &sigAct.sa_mask ); - sigaddset( &sigAct.sa_mask, signal ); -// sigaction( signal, &sigAct, 0 ); - return sigAct; -} Timer::Timer( const int signal ) : m_signal( signal ) - , m_sigAction( sigActionInit( m_sigAction , m_signal ) ) , m_timerId( 0 ) , m_periodic( false ) , m_running( true ) @@ -43,8 +22,6 @@ Timer::~Timer() its.it_value.tv_sec = 0; its.it_value.tv_nsec = 0; timer_settime( m_timerId, 0, &its, 0 ); - -// pthread_sigmask( SIG_UNBLOCK, &m_mask, 0 ); } @@ -85,8 +62,11 @@ void Timer::wait() long* tidp; siginfo_t sigInfo; + sigset_t sigSet; + sigemptyset( &sigSet ); + sigaddset( &sigSet, m_signal ); - sigwaitinfo( &(m_sigAction.sa_mask), &sigInfo); + sigwaitinfo( &sigSet, &sigInfo); if ( not m_running ) return; tidp = (long*)sigInfo.si_value.sival_ptr; @@ -99,7 +79,7 @@ void Timer::wait() if ( m_periodic ) { while ( m_running ) { - sigwaitinfo( &(m_sigAction.sa_mask), &sigInfo); + sigwaitinfo( &sigSet, &sigInfo); if ( not m_running ) return; tidp = (long*)sigInfo.si_value.sival_ptr; diff --git a/test/test_Timer.hpp b/test/test_Timer.hpp index 6a31b68..f00711a 100644 --- a/test/test_Timer.hpp +++ b/test/test_Timer.hpp @@ -77,7 +77,7 @@ private: m_counter++; count++; if ( count >= m_maxPeriodicCount ) { - stopTimer(); + stop(); } }