alarm.c 429 B

1234567891011121314151617181920
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #include <unistd.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <signal.h>
  7. void handler (int signal)
  8. {
  9. printf("alarm goes off\n");
  10. }
  11. int main(int argc, char ** argv)
  12. {
  13. signal(SIGALRM, &handler);
  14. alarm(1);
  15. sleep(3);
  16. return 0;
  17. }