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