Advertisement
patryk4815

Untitled

Feb 3rd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #include <sys/wait.h>
  5.  
  6. pid_t getpid(void);
  7. pid_t getppid(void);
  8.  
  9. int main(){
  10.     int i=0,j=0,pid,k,x;
  11.     pid=fork();
  12.     if(pid==0){
  13.         for(i=0;i<20;i++){
  14.             for(k=0;k<10000;k++);
  15.             printf("Child: %d\n",i);
  16.         }
  17.     }
  18.     else{
  19.         wait(0);
  20.         printf("**** Wznowienie rodzica **** \n");
  21.         for(j=0;j<20;j++){
  22.             for(x=0;x<10000;x++);
  23.             printf("Rodzic: %d\n",j);
  24.         }
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement