Mac 10.8.2 では、gfortran 4.7.2 を使用して次のコードをコンパイルします。
program test
write(*, *) isatty(6)
end program test
プログラムは応答せず、戻りません。何か案が?
出力が得られない理由はよくわかりませんが、Linux で gfortran 4.7.2 を使用すると問題なく動作します。C への独自のインターフェイスをisatty
作成することで違いが生じるかどうかを試すことができます。
program test
implicit none
interface
function my_isatty(fd) bind(C, name = 'isatty')
use, intrinsic :: iso_c_binding, only: c_int
integer(c_int) :: my_isatty
integer(c_int), value :: fd
end function
end interface
! Standard output should be at 1 in C:
print*, my_isatty(1)
end program test
次の出力が得られます。
$ ./a.out
1
$ ./a.out > b && cat b
0