ronyal

Untitled

Nov 19th, 2017
134
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 <stdlib.h>
  3. int main()
  4. {
  5. int i ,childPid;
  6.                 printf("\n I am the father and my pid = %d\n", getpid());
  7.  
  8.  
  9.                 for(i=1;i<=10;i++)
  10. {  
  11.                 childPid=fork();
  12.                 if(childPid > 0 )
  13.                 wait();
  14.                 else
  15.                     if (childPid == 0 )
  16.                         {
  17. printf("I am child, My PID is: %d  I am child number %d\n",getpid(),i);
  18. exit(0);
  19. }
  20.                         else
  21.         {
  22.         printf("\nfatel error num#ron_yalensky");
  23.         exit(1);       
  24.         }
  25.  
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment