alarm.c 253 B

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