This isn't possible to do in a console, since stream redirection always forms an acyclic graph.
To get the cyclic redirect you are looking for, you can code up a small program that invokes both of your executables, and manages the wiring of the input and output streams of each process. Each pair of streams that are connected (an input stream and output stream from each program) will need a thread to pull data from the output stream and push this into the input stream. So, you will need 2 threads, since there are 2 sets of input/output stream pairs.
Here are the steps to connecting the various streams:
- create two buffers, B1 and B2.
- launch program 1, (P1) and fetch the input and output stream handles.
- connect P1 input to the input side of buffer B1, and P1 output to the output side of buffer B2.
- launch program 2, (P2) and fetch the input and output stream handles
- connect P2 input to the input side of buffer B2, and P2 output to the output side of buffer B1. (note that this B1/B2 is reversed from P1 connection above.)
The buffers are active threads, reading from the input side and writing to the output side.
The buffer will have to detect the end of stream on the input side and close the output side accordingly. When both sides are closed, the thread running the buffer can exit.