Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
int main(){
int filho1,filho2,filho3;
filho1 = fork();
if (filho1 == 0){
printf("[%d] Sou o filho1!\n", getpid());
printf("[%d] O meu pai é: %d\n", getpid(), getppid());
}
filho2 = fork();
if (filho2 == 0){
printf("[%d] Sou o filho2!\n", getpid());
printf("[%d] O meu pai é: %d\n", getpid(), getppid());
}
filho3 = fork();
if (filho3 == 0){
printf("[%d] Sou o filho3!\n", getpid());
printf("[%d] O meu pai é: %d\n", getpid(), getppid());
}
return 0;
}

