I see that you marked the thread as solved. One thing I like to do if I self-solve is to post my result. In this case, the problem here was that you were waiting for a signal from the child process which would not occur unless that child exited; therefore the parent would never see a signal and end up sending data across the pipe. Another thing to note here is that your buffer of 30 characters was too short for the text string you created, and I'm very surprised that you didn't get a warning about that when you compiled; especially considering that it was C++ and those parsers are typically more strict than gcc.
Here are some minor modifications. I tend to do simple examples using solely C and also didn't do this in Windows, as I suspect you did with the namespace declaration, so sorry it's in C and for Linux. In this case for it works properly. It's style mostly, but I didn't see the need for an else clause since the child will exit and never enter that code portion.
Code:
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdlib.h>
int main()
{
int status, result=0;
int pfds[2]; //a file descriptor
char buf[64] = "recieved value from child process";
pid_t pid;
pipe(pfds);
pid = fork();
if(pid == -1) {
printf("error");
return;
}
if(pid == 0) {
result = 3;
printf("Result is: %d\n", result);
close(pfds[1]);
read(pfds[0], buf, sizeof(buf));
exit(0);
}
close(pfds[0]);
write(pfds[1],buf, sizeof(buf));
while(wait(&status) != pid) {
;;
}
printf("Parent exiting\n");
return 0;
}