Advertisement
SIKER_98

zad7

Dec 14th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <signal.h>
  5. #include <sys/signal.h>
  6. #include <ctype.h>
  7. #include <sys/wait.h>
  8.  
  9.  
  10. int stop = 0;
  11.  
  12. int main() {
  13. FILE *input = fopen("input.txt", "r");
  14. FILE *output = fopen("output.txt", "w");
  15. int p0, p1, p2;
  16. char znak;
  17. p0 = getpid();
  18. printf("p0: %d\n", p0);
  19.  
  20. if ((p1 = fork()) == 0) {
  21. while (stop != 1) {
  22. p1 = getpid();
  23. printf("p1: %d\n", p1);
  24. kill(p1, SIGINT);
  25. }
  26. exit(0);
  27. }
  28.  
  29.  
  30. if ((p2 = fork()) == 0) {
  31. while (stop != 1) {
  32. p2 = getpid();
  33. printf("p2: %d\n", p2);
  34. kill(p2, SIGINT);
  35. }
  36. exit(0);
  37. }
  38.  
  39.  
  40. wait(NULL);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement