1 #include <signal.h> 2 #include <unistd.h> 3 #include <stdio.h> 4 #include <time.h> 5 6 7 void 8 handler(int signal) 9 { 10 printf( "inside handler()\n" ); 11 } 12 13 14 int 15 main(int argc, char* argv[]) 16 { 17 struct sigaction signalAction; 18 sigset_t blockedSignalSet; 19 20 sigfillset(&blockedSignalSet); 21 sigdelset(&blockedSignalSet, SIGALRM); 22 23 sigemptyset(&signalAction.sa_mask); 24 signalAction.sa_flags = 0; 25 signalAction.sa_handler = handler; 26 sigaction(SIGALRM, &signalAction, NULL); 27 28 fprintf(stdout, "before sigsuspend()\n"); 29 alarm(2); 30 sigsuspend(&blockedSignalSet); 31 fprintf(stdout, "after sigsuspend()\n"); 32 33 return 0; 34 } 35