Mutual piping on linux
- by user21919
I would like the output of A to be input for B and at the same time the output of B to be the input for A, is that possible?
I tried the naïve thing: creating named pipes for A (pipeA) and B (pipeB) and then:
pipeB | A | pipeA &
pipeA | B | pipeB &
But that does not work (pipeB is empty and switching the order would not help either).
Any help would be appreciated.
Example:
Command A could be compiled form of this C program:
#include <stdio.h>
int main()
{
printf("0\n");
int x = 0;
while (scanf("%d", &x) != EOF)
{
printf("%d\n", x + 1);
}
return 0;
}
Command B could be compiled form of this C program:
#include <stdio.h>
int main()
{
int x = 0;
while (scanf("%d", &x) != EOF)
{
printf("%d\n", x + x);
}
return 0;
}