The problem with named pipes and fortran

I am trying to communicate between some fortran processes through named pipes. However, given even a very simple toy example, I ran into problems. Here is my code:

  program testfifo

  implicit none

  integer status

  write(*,*) "hello"
  call flush()

  open(unit=11,file="MyNamedPipe",action='write',form ='unformatted'
 $     ,iostat=status);
  close(11)

  write(*,*) "by"
  call flush()

  return
  end program testfifo    

If I run it with a regular file, it works:

/fortran > rm -f MyNamedPipe && touch MyNamedPipe
/fortran > gfortran -o testfifo testfifo.f 
/fortran > ./testfifo 
 hello
 by

However, when starting from fifo, my program gets stuck:

/fortran > rm -f MyNamedPipe && mkfifo MyNamedPipe
/fortran > gfortran -o testfifo testfifo.f 
/fortran > ./testfifo 
 hello
^C

I have no error messages. Also, I tried changing the formatted open format ↔ unformatted, with error = 100 to handle errors, etc., but that didn't help. Here are some of my system characteristics:

Linux lin45 3.2.0-4-amd64 # 1 SMP Debian 3.2.54-2 x86_64 GNU / Linux
gfortran 4.6.2
gcc 4.6.2
g ++ 4.6.2

. , - . , - , , - - /. .

. , , #n , , , . , , . Mac. - Linux. Mac:

Mac OS X 10.7.5
Xcode 4.5
gfortran 4.6.1
gcc 4.2.1
g++ 4.2.1

+4
1

. , action="write" .

    program testfifo

    implicit none

    integer status

    write(*,*) "hello"
    call flush()

    open(unit=11,file="MyNamedPipe",access='stream'                    &
 &   ,form ='unformatted', iostat=status)
    write(11) status
    print *, status
    close(11)

    write(*,*) "by"
    call flush()

    end program testfifo  

stream - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30162

+3

Source: https://habr.com/ru/post/1529249/


All Articles