如何使用alarm()函数
#include<stdio.h>#include<sys/types.h>
#include<unistd.h>
#include<stdlib.h>
#include<signal.h>
void signal_handler(int signo)
{
switch(signo)
{
case SIGALRM:
printf("ALARM received\n");
break;
default:
printf("Signal [%d] received\n",signo);
break;
}
}
int main(int argc,char **argv)
{
signal(SIGALRM,signal_handler);
alarm(2);
return 0;
}
运行结果并没有打印出来,我这个alarm()到底哪里用得不对啊??