Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <signal.h>
  6.  
  7. void funkcja(int sygnal)
  8. {
  9. printf("Potomek odebral sygnal nr %d (SIGINT)\n",sygnal);
  10. }
  11.  
  12. int main()
  13. {
  14. int pid;
  15.  
  16. pid=fork();
  17.  
  18. if(pid == -1)
  19. exit(EXIT_FAILURE);
  20.  
  21. if(pid==0)
  22. {
  23. signal(SIGINT,funkcja);
  24. pause();
  25. return 0;
  26. }
  27. else
  28. {
  29. sleep(1);
  30. kill(pid,SIGINT);
  31. }
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement