Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(x = 0; x <2 ; x++)
- {
- pid2 = fork();
- if(pid2 == -1)
- {
- perror("Error fork hijo.\n");
- exit(-1);
- }else if (pid2 == 0)
- {
- for (y = 0; y <3 ; y++ )
- {
- printf("Soy un hijo\n");
- pidSons = fork();
- if(pidSons == -1)
- {
- perror("Error fork nieto.\n");
- exit(-1);
- }else if(pidSons == 0)
- {
- printf("Soy un nieto\n");
- srand(getpid());
- sleep(wait_time());
- exit(binOut());
- } else if (pidSons > 0)
- {
- waitpid(pidSons,&status2, 0);
- enfermo = WEXITSTATUS(status2);
- exit(enfermo);
- }
- }
- } else
- {
- waitpid(pid2, &status3, 0);
- enfermo2 = WEXITSTATUS(status3);
- sumaenfermos += enfermo2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement