#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

main()     
{          
  pid_t filhoID;
  int estado;

  if ((filhoID= fork()) == -1) {
     printf("O fork falhou\n");
     exit(1);
  }
  if (filhoID==0) 
    printf("Sou o filho com pid=%ld\n",(long)getpid());
  else if (wait(&estado) != filhoID)
    printf("Um sinal interrompeu o wait()\n");
  else
    printf("Sou o pai com pid=%ld\n",(long)getpid());
  exit(0);
}
