Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdio.h>
  3.  
  4. #define MAX_CHILDS 10
  5.  
  6. int main()
  7. {
  8.   int child_count=0;
  9.   //pid_t child_id;
  10.   do_fork:
  11.   printf("***********************************\n");
  12.   printf("FORK TEST\n");
  13.   pid_t child_id = fork();
  14.   if(child_id == 0)
  15.   {
  16.     child_count ++;
  17.     printf("Hello I am the child %d\n", child_count);
  18.     if(child_count < MAX_CHILDS)
  19.       goto do_fork;
  20.   }
  21.   else
  22.       printf("I am the parent, and my child has the process id %d\n", child_id);
  23.   printf("####################################\n");
  24.   return 1337;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement