2017-07-09 3 views

Répondre

0
main 
    | 
    | 
fork --- (first child) 
    | 
    | 
fork --- (second child) 
    | 
    | 
fork --- (third child) 

void forktest() 
{ 
    printf("L0\n"); 
    if (fork() != 0) <----- first child, only parent goes inside the if 
    { 
     printf("L1\n"); 
     if (fork() != 0) <------ second child, only parent goes inside the if 
     { 
      printf("L2\n"); 
      fork();  <------ third child 
     } 
    } 
    printf("Bye\n"); 
} 

C'est, 3 processus créés par le principal.