1

I'm on Windows, although I could be on Linux so solutions for either are welcome.

I have a program that is essentially a game with 4 players that take an instruction from each of those players. Basically the idea is to have 4 groups to create an AI for this game. I need to route the stdout of all 4 of these AI programs to the stdin of my contest program. How would I do that?

3
  • mkfifo, CreatePipe ?
    – Alex
    Feb 3, 2017 at 1:53
  • Does one pipe work for multiple stdout? Feb 3, 2017 at 2:19
  • See example in my answer
    – Alex
    Feb 3, 2017 at 7:08

1 Answer 1

0

Named pipes accepts output from anybody (if permissions allow it)

#!/bin/bash

mkfifo -m 666 /tmp/myfifo.pipe

( echo 'Proc1' 1> /tmp/myfifo.pipe ) &
PID1=$!
( echo 'Proc2' 1> /tmp/myfifo.pipe ) &
PID2=$!
( echo 'Proc3' 1> /tmp/myfifo.pipe ) &
PID3=$!

 cat </tmp/myfifo.pipe > result.txt

wait $PID1 $PID2 $PID3

rm -f /tmp/myfifo.pipe

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .