-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4af1147
commit 9d23638
Showing
6 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <stdbool.h> | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int n; | ||
if ((n = fork()) == 0) | ||
{ | ||
// Fils 1 | ||
// exécution programme ex5 | ||
execve("./ex5bis", NULL, NULL); | ||
printf("\n"); | ||
// on attends on sait jamais | ||
sleep(1); | ||
exit(0); | ||
} | ||
else | ||
{ | ||
if ((n > 0)) | ||
{ | ||
// père | ||
//printf("Père : Processus père avec PID : %i\n", getpid()); | ||
|
||
// Création de fils | ||
int n2; | ||
if ((n2 = fork()) == 0) | ||
{ | ||
// Fils 2 | ||
// exécution programme ex5 | ||
execve("./ex5", NULL, NULL); | ||
printf("\n"); | ||
// on attends on sait jamais | ||
sleep(1); | ||
exit(0); | ||
} | ||
else if (n2 < 0) | ||
{ | ||
printf("Erreur\n"); | ||
return -1; | ||
} | ||
} | ||
else | ||
{ | ||
// Erreur | ||
printf("Erreur de PID\n"); | ||
return -1; | ||
} | ||
} | ||
} |