Facebook
From Mature Water Vole, 3 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 52
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/wait.h>
  4.  
  5. int main(){
  6.         int Liczba, ChildPid, i, Suma;
  7.         Suma = 0;
  8.         if((ChildPid=fork() ) == 0){
  9.                 Suma = 0;
  10.                 for(i=0; i<5; i++){
  11.                         Suma++;
  12.                 }
  13.         printf("\n Proces potomny pid(%d) --> Suma=%d", getpid(), Suma);
  14.         exit(0);
  15.  
  16.         }
  17.         wait(0);
  18.         printf("\n Proces macierzysty pid(%d) --> Suma%d", getpid(), Suma);
  19.         printf("\n");
  20. }