no need for a sigaction

master
Denes Matetelki 14 years ago
parent 34ed5628ec
commit 06eebadba2

@ -41,7 +41,6 @@ private:
Timer& operator=( const Timer& ); Timer& operator=( const Timer& );
int m_signal; int m_signal;
struct sigaction m_sigAction;
timer_t m_timerId; timer_t m_timerId;
bool m_periodic; bool m_periodic;
bool m_running; bool m_running;

@ -3,31 +3,10 @@
#include "Common.hpp" #include "Common.hpp"
#include <signal.h> // sigset_t #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 ) Timer::Timer( const int signal )
: m_signal( signal ) : m_signal( signal )
, m_sigAction( sigActionInit( m_sigAction , m_signal ) )
, m_timerId( 0 ) , m_timerId( 0 )
, m_periodic( false ) , m_periodic( false )
, m_running( true ) , m_running( true )
@ -43,8 +22,6 @@ Timer::~Timer()
its.it_value.tv_sec = 0; its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 0; its.it_value.tv_nsec = 0;
timer_settime( m_timerId, 0, &its, 0 ); timer_settime( m_timerId, 0, &its, 0 );
// pthread_sigmask( SIG_UNBLOCK, &m_mask, 0 );
} }
@ -85,8 +62,11 @@ void Timer::wait()
long* tidp; long* tidp;
siginfo_t sigInfo; 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; if ( not m_running ) return;
tidp = (long*)sigInfo.si_value.sival_ptr; tidp = (long*)sigInfo.si_value.sival_ptr;
@ -99,7 +79,7 @@ void Timer::wait()
if ( m_periodic ) { if ( m_periodic ) {
while ( m_running ) { while ( m_running ) {
sigwaitinfo( &(m_sigAction.sa_mask), &sigInfo); sigwaitinfo( &sigSet, &sigInfo);
if ( not m_running ) return; if ( not m_running ) return;
tidp = (long*)sigInfo.si_value.sival_ptr; tidp = (long*)sigInfo.si_value.sival_ptr;

@ -77,7 +77,7 @@ private:
m_counter++; m_counter++;
count++; count++;
if ( count >= m_maxPeriodicCount ) { if ( count >= m_maxPeriodicCount ) {
stopTimer(); stop();
} }
} }

Loading…
Cancel
Save