当前位置: 技术问答>linux和unix
linux下该如何取消用setitimer设置的定时器呢?
来源: 互联网 发布时间:2017-01-29
本文导语: void init_sigaction(void) { struct sigaction tact; tact.sa_handler = drawFrame_proc; tact.sa_flags = 0; sigemptyset(&tact.sa_mask); sigaction(SIGALRM, &tact, NULL); } void init_time() { struct itimerval value; va...
void init_sigaction(void)
{
struct sigaction tact;
tact.sa_handler = drawFrame_proc;
tact.sa_flags = 0;
sigemptyset(&tact.sa_mask);
sigaction(SIGALRM, &tact, NULL);
}
void init_time()
{
struct itimerval value;
value.it_value.tv_sec = 0;
value.it_value.tv_usec = 40000;
value.it_interval = value.it_value;
setitimer(ITIMER_REAL, &value, NULL);
}
请问该如何取消用setitimer设置的定时器呢。谢谢!
{
struct sigaction tact;
tact.sa_handler = drawFrame_proc;
tact.sa_flags = 0;
sigemptyset(&tact.sa_mask);
sigaction(SIGALRM, &tact, NULL);
}
void init_time()
{
struct itimerval value;
value.it_value.tv_sec = 0;
value.it_value.tv_usec = 40000;
value.it_interval = value.it_value;
setitimer(ITIMER_REAL, &value, NULL);
}
请问该如何取消用setitimer设置的定时器呢。谢谢!
|
setitimer设置it_interval和it_value为零。
|
void uninit_time()
{
struct itimerval value;
value.it_value.tv_sec = 0;
value.it_value.tv_usec = 0;
value.it_interval = value.it_value;
setitimer(ITIMER_REAL, &value, NULL);
}
{
struct itimerval value;
value.it_value.tv_sec = 0;
value.it_value.tv_usec = 0;
value.it_interval = value.it_value;
setitimer(ITIMER_REAL, &value, NULL);
}