In child, I write to fifo "sample" and read it in parent. In the code below, parent writes terminal "sample" and wait, it doesn't exit from read function.
pid_t p;
int fd;
char str[]="sample";
char ch;
mkfifo("myfifo", FIFO_PERMS);
fd = open("myfifo", O_RDWR);
p=fork();
if(!p){
printf("write %d byte\n", write(fd, str, 6));
}
else{
wait(NULL);
while(read(fd, &ch, 1)>0)
write(STDOUT_FILENO, &ch, 1);
close(fd);
unlink("myfifo");
}