alarm.c 251 B

123456789101112131415
  1. #include <signal.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. void handler(int signal) {
  6. printf("alarm goes off\n");
  7. }
  8. int main(int argc, char** argv) {
  9. signal(SIGALRM, &handler);
  10. alarm(1);
  11. sleep(3);
  12. return 0;
  13. }