1

我尝试做的事情:

创建管道 (FIFO)。

将管道的输出重定向到标准输入 (&1)。

将管道的输入重定向到第 4 个描述符 (&4)。

运行我的程序(它应该复制它的父描述符,指向我的管道)。

向 &4 写入一些东西(FIFO 输入)。

让它由我的程序读取(来自 FIFO 输出)。

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

不幸的是,它根本不起作用。我究竟做错了什么?

4

0 回答 0