http://topic.csdn.net/u/20090219/11/738374C4-C9B5-4A79-B671-1C844A2668B1.html
贴个Linux的吧,不清楚的自己man man。
-
C/C++ code
-
#include < stdio.h > #include < unistd.h > #include < sys / time.h > #include < signal.h > void alarm_handler( int signum) { printf( " hello, there!\n " ); } int main( void ) { struct itimerval timer; timer.it_interval.tv_sec = 1 ; timer.it_interval.tv_usec = 0 ; timer.it_value.tv_sec = 1 ; timer.it_value.tv_usec = 0 ; setitimer(ITIMER_REAL, & timer, NULL); signal(SIGALRM, alarm_handler); while ( 1 ) pause(); return 0 ; }