Read on closed named pipe blocks

前端 未结 2 655
终归单人心
终归单人心 2021-01-24 13:24

I am trying to read from a named pipe (FIFO) with Fortran. Reading the data works, but the Fortran program does not seem to notice when the pipe is closed on the other end; rea

2条回答
  •  萌比男神i
    2021-01-24 13:48

    I don't know much about fortran, but I do know you could reproduce the hanging behavior in C by using a read/write mode in your open (for example fopen("test", "r+")

    The pipe doesn't get an EOF until the number of writable file descriptors on it drops to 0. When your read file descriptor is also writable, you never get EOF.

    So my guess is that fortran opens in read/write mode by default, and you need to tell it not to do that. This question about a fortran readonly flag may help.

提交回复
热议问题