#include #include #include int main() { pid_t pid = fork(); if (pid < 0) { perror("Erreur lors de la création du processus fils"); exit(1); } else if (pid == 0) { for (int i = 0; i < 10; i++) { printf("pid fils: %d (pid du père: %d)\n", getpid(), getppid()); usleep(1000000); } exit(42); } else { for (int i = 0; i < 10; i++) { printf("PID PÈRE: %d (PID DU FILS: %d)\n", getpid(), pid); usleep(1000000); } int status; waitpid(pid, &status, 0); printf("Code renvoyé par le fils : %d\n", WEXITSTATUS(status)); } return 0; }