#define READ  0
#define WRITE 1
char *msg= "Ola papa!";
main() {
  int fd[2], msgSize=strlen(msg)+1;
  char buf[100];

  printf("strlen = %d   msg size = %d\n", strlen(msg), msgSize);

  pipe(fd);                        // Um programa em que o processo-filho 
  if (fork()==0) {                 // envia ao processo-pai uma mensagem
    close(fd[READ]);
    write(fd[WRITE],msg,msgSize);
    close(fd[WRITE]);
  }
  else {
    close(fd[WRITE]);
    msgSize= read(fd[READ],buf,100);
    printf("Nbytes:%d, Msg:%s\n",msgSize,buf);
    close(fd[READ]);
  }
  exit(0);
}