/*
 * Exemplo de uso de semáforos e fork. O filho será desbloqueado?
 */ 


#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

#include <semaphore.h>

int main() {
  sem_t sem;

  sem_init(&sem, 1, 0);

  if (fork()){
    printf("Processo pai.\n");
    sleep(5);
    sem_post(&sem);
  }
  else {
    sem_wait(&sem);
    printf("Processo filho.\n");
  }

 
  return 1;
}