Advertisement
Benjamin_Loison

C fork

Nov 20th, 2020 (edited)
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. case C_MULT:
  2.         ;
  3.         fils0 = fork();
  4.         if(fils0 == 0)
  5.         {
  6.             exit(compute(expr->left));
  7.         }
  8.         else
  9.         {
  10.             fils1 = fork();
  11.             if(fils1 == 0)
  12.             {
  13.                 exit(compute(expr->right));
  14.             }
  15.         }
  16.  
  17.         waitpid(fils0, &status, 0);
  18.         if(WIFEXITED(status))
  19.             sum = WEXITSTATUS(status);
  20.         waitpid(fils1, &status, 0);
  21.         if(WIFEXITED(status))
  22.             sum *= WEXITSTATUS(status);
  23.         return sum;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement