Tobiahao

S01_LAB01_06

Nov 12th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. /*
  2. Napisz program, który wyśle do siebie sygnał SIGALRM i obsłuży go.
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <signal.h>
  8. #include <unistd.h>
  9.  
  10. void sigalrm_function(int signum)
  11. {
  12.     printf("Sygnal SIGALRM wylapany i obsluzony!\n");
  13.     exit(EXIT_SUCCESS);
  14. }
  15.  
  16. int main(void)
  17. {
  18.     if(signal(SIGALRM, sigalrm_function) == SIG_ERR){
  19.         fprintf(stderr, "Signal error\n");
  20.         return EXIT_FAILURE;
  21.     }
  22.  
  23.     printf("Sygnal zostanie wyslany za sekunde!\n");
  24.     alarm(1);
  25.  
  26.     while(1){}
  27.  
  28.     return EXIT_SUCCESS;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment