|
发表于 2005-1-19 11:04:05
|
显示全部楼层
[code:1]
int init_Timer()
{
struct itimerval timerv;
struct sigaction siga;
siga.sa_handler = Run;
siga.sa_flags = 0;
m_iCount = 0;
memset(&siga.sa_mask, 0, sizeof(sigset_t));
sigaction(TIME_SIGNAL, &siga, &m_oldalarm);
timerv.it_interval.tv_sec = 10;
timerv.it_interval.tv_usec = 0;
timerv.it_value = timerv.it_interval;
if (setitimer(ITIMER_REAL, &timerv, &m_oldtimer))
{
fprintf(stderr, "TIMER: setitimer call failed!\n");
perror("setitimer");
}
return TIME_SUCCESS;
}[/code:1]
run就是你想要做的事情的函数。。。 |
|