From e14c56bd902726a577053309eff24941602f26fe Mon Sep 17 00:00:00 2001 From: Xu Meng Date: Mon, 16 Dec 2019 15:26:54 +0100 Subject: [PATCH] ibmi: fix the false isatty() issue on IBMi On IBMi PASE isatty() always returns true for stdin, stdout and stderr. Use ioctl() instead to identify whether it's actually a TTY. PR-URL: https://github.com/libuv/libuv/pull/2565 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Richard Lau --- src/unix/tty.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unix/tty.c b/src/unix/tty.c index e7c520f7..2385911c 100644 --- a/src/unix/tty.c +++ b/src/unix/tty.c @@ -293,7 +293,14 @@ uv_handle_type uv_guess_handle(uv_file file) { if (file < 0) return UV_UNKNOWN_HANDLE; +#if defined(__PASE__) + /* On IBMi PASE isatty() always returns true for stdin, stdout and stderr. + * Use ioctl() instead to identify whether it's actually a TTY. + */ + if (!ioctl(file, TXISATTY + 0x81, NULL) || errno != ENOTTY) +#else if (isatty(file)) +#endif return UV_TTY; if (fstat(file, &s))