Advertisement
paulogp

Signal

Jul 14th, 2011
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. // sinal
  2.  
  3. // Apple Xcode
  4. // paulogp
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <unistd.h>
  9. #include <stdlib.h>
  10. #include <time.h>
  11. #include <signal.h>
  12.  
  13. void myhandler(int signum)
  14. {
  15.     printf("entrada na funcao\n");
  16. }
  17.  
  18. int main (int argc, const char * argv[])
  19. {
  20.     printf("inicio do processo\n");
  21.    
  22.     // ignorar um sinal: signal(nome_do_sinal, SIG_IGN)
  23.     signal(SIGPIPE, SIG_IGN);
  24.    
  25.     struct sigaction act;
  26.     act.sa_handler = myhandler;
  27.     act.sa_flags = 0;
  28.     sigemptyset(&(act.sa_mask));
  29.     sigaction(SIGINT, &act, NULL);
  30.    
  31.     printf("fim do processo\n");
  32.    
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement