/* if we get here we are the parent process */ printf(“waiting for alarm to go off\n”); (void) signal(SIGALRM, ding); pause(); if (alarm_fired) printf(“Ding!\n”); printf(“done\n”); exit(0); }
当我们运行这个程序时,当他等待模拟的警报时钟时会等待5秒。
$ ./alarm alarm application starting waiting for alarm to go off <5 second pause> Ding! done $