Processus -utiliser la fonction wait

hannaria Messages postés 23 Statut Membre -  
hannaria Messages postés 23 Statut Membre -
hi!!
please ...can u helpe me to solve this 2 question


1-Editer le programme . Compilez-le puis éxécutez-le en tâche
de fond : utiliser la commande : $./a.out &
Quel est l'état du processus fils (pensez à utiliser la commande ps avant la
terminaison du process père)


2. Proposer une solution pour éviter les états orphelin et zombie en
utilisant la fonction wait.


#include <stdio.h>
#include <stdlib.h>
int main(){

pid_t pid;
pid=fork();

if (pid == 0) {
printf ("je suis le fils, mon pid est %d, le pid de mon pere est %d \n",getpid(),getppid() );
exit(0);
}
else {
sleep(5);
printf ("je suis le père , mon pid est %d, le pid de mon fils est %d \n", getpid(), pid);
exit(0);
}
return 0;
}
A voir également:

1 réponse

fiddy Messages postés 11653 Statut Contributeur 1 847
 
On n'est pas là pour faire vos devoirs.
Dis-nous plutôt ce que tu comprends pas comme concept pour que tu puisses répondre toi-même à l'exo.
1
hannaria Messages postés 23 Statut Membre
 
hi fiddy.....am sorry but i dont mean that.....(solve my homework)
the problem is that in my class we did not study yet (the fonction wait.....and etat of processus)...... we are in holiday and i tray alone to study them..this whay i ask u this (may be for u) a stupid question


so in order of that let me ask my question by other way

when we use the foction wait???

and how can i knew that the child is orphan or zombie???
0
fiddy Messages postés 11653 Statut Contributeur 1 847
 
So, the best thing I can do for you is to give you a link where you will able to learn : http://www.cours.polymtl.ca/inf2610/documentation/notes/chap3.pdf

For the function wait(), you have already asked the question in another post. So, thanks for not asking the same question twice.

And then, here French is spoken.

Kind regards,
0
hannaria Messages postés 23 Statut Membre
 
ok !!!merci beaucoup fiddy
0