#include
#include
#include
#include
#include
int count = 0;
void set_timer()
{
struct itimerval itv, oldtv;
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 1000;
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = 1000;
setitimer(ITIMER_REAL, &itv, &oldtv);
}
void sigalrm_handler(int sig)
{
count++;
}
int main( )
{
signal(SIGALRM, sigalrm_handler);
set_timer();
while(count < 10000){
}
printf("count = %d\n", count);
exit(0);
}
阅读(2522) | 评论(1) | 转发(1) |