Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- #define MAX_CHILDS 10
- int main()
- {
- int child_count=0;
- //pid_t child_id;
- do_fork:
- printf("***********************************\n");
- printf("FORK TEST\n");
- pid_t child_id = fork();
- if(child_id == 0)
- {
- child_count ++;
- printf("Hello I am the child %d\n", child_count);
- if(child_count < MAX_CHILDS)
- goto do_fork;
- }
- else
- printf("I am the parent, and my child has the process id %d\n", child_id);
- printf("####################################\n");
- return 1337;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement