Bonjour tous le monde voila j'essai de finir un travail mais j'y arrive pas avec quelque lacune en programmation , mon bute c'est que le processus fils se termine toujours avant son pere et que le fils renvoi (1) pour fils1
(2) pour fils2 je vous en remercie d'avance
voila mon programme
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
main ()
{
int ret_fork1, ret_fork2, etat, m,pid;
ret_fork1 = fork();
if(ret_fork1) /* PERE */
{
printf ("PID(apres fork1) = %d - PPID=%d Cree FILS1 %d\n",
(int)getpid(), (int)getppid(), ret_fork1 );
wait(&m);
}
else
printf ("PID(apres fork1) = %d - PPID=%d\n",
(int)getpid(), (int)getppid() );
ret_fork2 = fork();
if(ret_fork2)
{
printf ("PID(apres fork2) = %d - PPID=%d Cree %d\n",
(int)getpid(), (int)getppid(),ret_fork2 );
wait(&m) ;
}
else
printf ("PID(apres fork2) = %d - PPID=%d\n",
(int)getpid(), (int)getppid() );
printf ("le fils de pid %d se termine avec le code %d \n",pid, m>>8 );
}