I am trying to get two fortran programs to communicate through a named pipe but the reading program is hanging. My command look like this:
> mkfifo /tmp/myfifo
> ./app/fortw /tmp/myfifo &
> ./app/fortr /tmp/myfifo
where fortw
prints the numbers 1 to 10 and 'fortr' reads them like this
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
It prints the numbers 1 - 6 and then hangs so i have to do fg
then C^C
to stop it.
If I replace ./app/fortr
with cat
, or an equivalent c++ program, then I get the numbers 1 to 10 as expected so the problem seems to be with the reading not the writing. But if I read from a normal file rather than a fifo, ./app/fortr
gives the expected result.
Should I expect to be able to get this to work, and it so, how?
UPDATE:
A more minimal example. If test contains the numbers 1 to 10, then
./app/fortr test
prints the numbers 1 to 10
but
./app/fortr <( cat test )
prints the numbers 1 to 6 and hangs