p fork wait exit ok
This commit is contained in:
parent
858cd39d49
commit
8b366a33f7
@ -29,10 +29,9 @@ int main(int argc, char *argv[])
|
|||||||
/**********************/
|
/**********************/
|
||||||
/* PARTIE A COMPLETER */
|
/* PARTIE A COMPLETER */
|
||||||
/**********************/
|
/**********************/
|
||||||
|
int infosRetour;
|
||||||
int res = fork();
|
int res = fork();
|
||||||
int max = atoi(argv[1]);
|
int max=atoi(argv[1]);
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
printf("ERREUR FORK\n");
|
printf("ERREUR FORK\n");
|
||||||
@ -44,23 +43,23 @@ int main(int argc, char *argv[])
|
|||||||
printf("Je suis le fils :\n");
|
printf("Je suis le fils :\n");
|
||||||
printf("pid : %d\n", getpid());
|
printf("pid : %d\n", getpid());
|
||||||
printf("ppid : %d\n", getppid());
|
printf("ppid : %d\n", getppid());
|
||||||
for (int i = 0; i < max; i++)
|
|
||||||
{
|
printf("Hush now quiet now It's time to go to bed for 3 seconds...\n");
|
||||||
printf("/");
|
sleep(3);
|
||||||
}
|
printf("I know this one ! :D");
|
||||||
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
exit(max);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /************************** PERE ***********************/
|
{ /************************** PERE ***********************/
|
||||||
wait(NULL);
|
wait(&infosRetour);
|
||||||
printf("Je suis le père :\n");
|
printf("Je suis le père :\n");
|
||||||
printf("pid : %d\n", getpid());
|
printf("pid : %d\n", getpid());
|
||||||
printf("ppid : %d\n", getppid());
|
printf("ppid : %d\n", getppid());
|
||||||
|
printf("%d", WEXITSTATUS(infosRetour));
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < max; i++)
|
|
||||||
{
|
|
||||||
printf("*");
|
|
||||||
}
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user