Has anyone had success calling `platform.posix.isa...
# kotlin-native
a
Has anyone had success calling
platform.posix.isatty
from K/N? It seems that
isatty(STDIN_FILENO)
always returns 0 on my machine (calling the built binary directly, not though gradle). Calling
isatty(fileno(stdout))
in the same way from a C program returns the expected values.
o
Copy code
nike@~/kotlin/2kotlin-native
>cat isa.kt
import platform.posix.*

fun main() {
  println(isatty(STDIN_FILENO))
}
nike@~/kotlin/2kotlin-native
>./dist/bin/konanc isa.kt -o i
nike@~/kotlin/2kotlin-native
>./i.kexe 
1
nike@~/kotlin/2kotlin-native
>uname -a
Darwin iMac-Nikolay.local 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64
what is your OS?
n
On Linux X64 the result is 1 (same result in both IntelliJ's Terminal and Gnome Terminal on Linux Mint 19.3), which is the same as Nikolay's program.
k
Fedora Rawhide K/N compiler 1.4.0 it return 0 from idea
It returns 1 if I run build executable on terminal
a
Hm, I'm using the mingw target on windows, maybe that has something to do with it?
o
Maybe you compile for different subsystem? Using appropriate Win32 API could be better here.
a
Hm, I just tried using the windows version,
_isatty(STDIN_FILENO)
, and still only get 0
a
That patch seems to be checking for false-positives, where
isatty
is returning 1 when they expect 0. I'm experiencing the opposite case.
And it doesn't happen when compiling C code with mingw directly.