1

我试图让两个 fortran 程序通过命名管道进行通信,但读取程序挂起。我的命令如下所示:

> mkfifo /tmp/myfifo
> ./app/fortw /tmp/myfifo &
> ./app/fortr /tmp/myfifo

wherefortw打印数字 1 到 10,'fortr' 像这样读取它们

open ( unit = nsave, file = outputfile , form = 'formatted', access = 'stream' )
do while ( .TRUE. )
read ( unit = nsave, fmt = *, end = 10), j
write( 6, *), j
end do

10 continue

它打印数字 1 - 6 然后挂起,所以我必须这样做fg才能C^C停止它。

如果我./app/fortrcat或等效的 c++ 程序替换,那么我会得到预期的数字 1 到 10,所以问题似乎出在阅读而不是写作上。但是,如果我从普通文件而不是 fifo 读取,则会./app/fortr给出预期的结果。

我是否应该期望能够让它发挥作用,所以,如何?

更新:

一个更简单的例子。如果 test 包含数字 1 到 10,则

./app/fortr test

打印数字 1 到 10

 ./app/fortr <( cat test )

打印数字 1 到 6 并挂起

4

0 回答 0