/* * Sample program for alarm system clock - No.27 * * alarm(2) - set an alarm clock for delivery of a signal * * Synopsis * #include * * unsigned int alarm(unsigned int seconds); * * Description * alarm arranges for a SIGALRM signal to be delivered to the * process in seconds seconds. * * If seconds is zero, no new alarm is scheduled. * * In any event any previously set alarm is cancelled. */ #include #include /* signal handler for SIGALRM signal */ void sig_alarm(int sig) { printf("recieved SIGALRM\n"); } main() { /* entry signal handler for SIGALRM signal to the signal handler table */ signal(SIGALRM, sig_alarm); alarm(2); printf("Please wait\n"); /* invoking this process sleep until SIGALRM is recieved */ pause(); printf("End\n"); exit(0); }