|
|
|
@ -3,31 +3,10 @@
|
|
|
|
|
#include "Common.hpp"
|
|
|
|
|
|
|
|
|
|
#include <signal.h> // sigset_t
|
|
|
|
|
#include <time.h> // timer_t
|
|
|
|
|
#include <string.h> // 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;
|
|
|
|
|
|
|
|
|
|