I’m using the setitimer function in order to set an ITIMER_VIRTUAL timer, using a pointer to some struct itimerval. this is a virtual timer (runs only when the process has control) and sends a SIGVTALRM signal the moment it reaches zero.
My question is – after calling setitimer, is there any way to disable an active timer, so this signal would not go off when the timer finishes? or is the only way to ignore it now would be setting a SIGNAL MASK ordering the program to ignore this signal?
Thanks!
According to the man page, just call
setitimer()again, with the same timer handle and theit_valuefield of the itimerval struct set to zero.You can disable it immeditately:
Or after it next fires: