ronyal

l3e2 niv

Nov 21st, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char* argv[]){
  5.     int i, pid;
  6.     printf("I am the parent! my pid = %d\n",getpid());
  7.     for(i=1; i<11; i++){
  8.         pid = fork();
  9.         if(pid !=0)
  10.             wait();
  11.         else{
  12.             printf("I'm a child!!, Child number = %d, my pid = %d\n",i ,getpid());
  13.             exit(0);
  14.         }
  15.     }
  16.     return 0;  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment