- 论坛徽章:
- 1
|
本帖最后由 sundae333 于 2015-05-21 10:41 编辑
#define SIGGETIMER (SIGRTMAX)
static void GlobalTimerHandler(int signo, siginfo_t* info, void* context)
{
CGeTimer *pTimer;
if( signo != SIGGETIMER )
return;
pTimer = (CGeTimer*)(info->si_ptr);
pTimer->handler();
}
函数是信号处理函数(实时信号64)
注册代码(sigaction):
sigemptyset(&sysact.sa_mask);
sysact.sa_flags = SA_SIGINFO;
sysact.sa_sigaction = GlobalTimerHandler;
sigaction(SIGGETIMER,&sysact,NULL);
问题:
发现有的时候siginfo_t* 这个参数带的值有的时候不是预期的,有的时候为NULL(出现几率不高)。
不理解是什么导致的,siginto_t*指针指向的sigqueue队列中的数据什么时候会被释放?
另外,信号是通过POSIX定时器发送的:
struct sigevent evp;
....
evp.sigev_notify = SIGEV_SIGNAL;
evp.sigev_signo = SIGGETIMER;
evp.sigev_value.sival_ptr = this;
nRes = timer_create(CLOCK_REALTIME, &evp, &m_timerID);
|
|