Use proper method of console identification (glibc).

This commit is contained in:
cheatfate 2020-09-30 16:34:10 +03:00
parent 4363df120f
commit 6ee4974c7f
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 2 additions and 5 deletions

View File

@ -260,12 +260,9 @@ elif defined(posix):
proc isConsoleRedirected(consoleFd: cint): bool =
## Returns ``true`` if console handle was redirected.
var mode: Termios
# This is how `isatty()` checks for TTY.
if tcGetAttr(consoleFd, addr mode) != cint(0):
let errCode = ioLastError()
if errCode == ENOTTY:
true
else:
false
true
else:
false