#include <stdio.
h>
#include <unistd.h>
Int main() {
Pid_t pid ;
// Processus père
Printf(« Je suis le processus père (PID : %d)\n », getpid()) ;
// Création du premier fils
Pid = fork() ;
If (pid < 0) {
Perror(« fork ») ;
Return 1 ;
} else if (pid == 0) {
// Processus fils 1
Printf(« Je suis le fils 1 (PID : %d, PID de mon père : %d)\n », getpid(),
getppid()) ;
Return 0 ;
// Création du deuxième fils
Pid = fork() ;
If (pid < 0) {
Perror(« fork ») ;
Return 1 ;
} else if (pid == 0) {
// Processus fils 2
Printf(« Je suis le fils 2 (PID : %d, PID de mon père : %d)\n », getpid(),
getppid()) ;
Return 0 ;
// Création du troisième fils
Pid = fork() ;
If (pid < 0) {
Perror(« fork ») ;
Return 1 ;
} else if (pid == 0) {
// Processus fils 3
Printf(« Je suis le fils 3 (PID : %d, PID de mon père : %d)\n », getpid(),
getppid()) ;
Return 0 ;
// Processus père (attend la fin des fils – facultatif)
// …
Return 0 ;