Advertisement
GoralWMoro

Untitled

Dec 7th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. //proces P4
  2.             switch(potomki[4] = fork()){
  3.                 case 0:
  4.                 {
  5.                     //proces P9
  6.                     switch(potomki[9] = fork()){
  7.                         case 0:
  8.                         {
  9.                             printf("P9:%d:%d\n", getpid(), getppid());
  10.                             exit(0);
  11.                         }
  12.                         case -1:
  13.                             printf("Blad funkcji fork");
  14.                             exit(1);
  15.                         default:
  16.                             wait(NULL); //oczekiwanie na zakończenie procesu potomnego
  17.                     }
  18.  
  19.                     printf("P4:%d:%d:%d\n", getpid(), getppid(), potomki[9]);
  20.                     exit(0);
  21.                 }
  22.                 case -1:
  23.                     printf("Blad funkcji fork");
  24.                     exit(1);
  25.                 default:
  26.                     wait(NULL); //oczekiwanie na zakończenie procesu potomnego
  27.  
  28.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement