Also, @GaurangTandon when you ran ./A < myfifo | ./B > myfifo didn't that hang?
Basically, the pipe there makes no sense, there's no output to pipe, you probably meant A < myfifo & (sending that to the background) and then B >myfifo.
But the main issue here is how named pipes work. When you run A < myfifo, that means "start reading from myfifo and wait until something is written to it". Then, B >myfifo writes to it. So A reads it, and exits. Which is why the command returns immediately.
@Fabby You can't pipe to a file.
Here, @GaurangTandon, I'm testing with these two little programs. Are they a good approximation of what your C++ code is trying to do?
@GaurangTandon You can, it is actually working as you want it to work, you just have no way of seeing it because all the output is going through the fifo.
If you add a line that prints something to another file, you will see that the output has been passed correctly .