What I try to do:
Create a pipe (FIFO).
Redirect output of the pipe to the stdin (&1).
Redirect input of the pipe to the 4th descriptor (&4).
Run my program (it should copy it's parent descriptors, pointing to my pipe).
Write something to &4 (FIFO input).
Have it read by my program (from FIFO output).
input_pipe=$(mktemp -u);
mkfifo $input_pipe;
exec 1<$input_pipe;
exec 4>$input_pipe;
rm $input_pipe; #this should not remove the pipe itself
my_program &
echo $'input to be read by my_program' >&4;
#my program's answer should appear in stdout
Unfortunately, it doesn't work at all. What am I doing wrong?