Está en la página 1de 3

#include<stdio.

h>
#include<sys/types.h>

main(void){

pid_t p2;
pid_t p3;
int aleatorio;

aleatorio = (rand()%(5-(2+1))+2);

//creo el hijo
p2=fork();

if( p2 == -1) {

printf("\n \t Error en la creacion de p2 ");


fflush(stdout);
}else
if( p2 == 0 ) {

p2=fork();

printf(" \n \t \t p2 creado ");


fflush(stdout);
if (p3 == -1) {

printf(" Error en la creacion de p3 ");


fflush(stdout);
}else{
if( p3 == 0 ){
printf(" proceso p3 empezando sentencia 5 ");
fflush(stdout);

sleep(srand(time(NULL)));
}
else{

p3=wait(NULL);
printf("\n \t \t p3 acabando sentencia 5 ");
fflush(stdout);

else{

p2=wait(NULL);
printf("\n \t p2 acabando sentencia 6");
fflush(stdout);
}#include<stdio.h>
#include<sys/types.h>

main(void){

pid_t p2;
pid_t p3;
int aleatorio;

aleatorio = (rand()%(5-(2+1))+2);

//creo el hijo
p2=fork();

if( p2 == -1) {

printf("\n \t Error en la creacion de p2 ");


fflush(stdout);
}else
if( p2 == 0 ) {

p2=fork();

printf(" \n \t \t p2 creado ");


fflush(stdout);
if (p3 == -1) {

printf(" Error en la creacion de p3 ");


fflush(stdout);
}else{
if( p3 == 0 ){
printf(" proceso p3 empezando sentencia 5 ");
fflush(stdout);

sleep(srand(time(NULL)));
}
else{

p3=wait(NULL);
printf("\n \t \t p3 acabando sentencia 5 ");
fflush(stdout);

else{

p2=wait(NULL);
printf("\n \t p2 acabando sentencia 6");
fflush(stdout);
}

También podría gustarte