diff options
author | Xu Meng <mengxumx@cn.ibm.com> | 2019-12-06 20:54:00 -0600 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-10 00:28:08 +0100 |
commit | 68874a617b5f6b43480f87bf18b681605a2f6f8c (patch) | |
tree | bfd6829222444c677dbff7b45096b34bcb026352 | |
parent | 6bdf8d106009e4ed0f3c323d0f0874a51acc8e08 (diff) | |
download | android-node-v8-68874a617b5f6b43480f87bf18b681605a2f6f8c.tar.gz android-node-v8-68874a617b5f6b43480f87bf18b681605a2f6f8c.tar.bz2 android-node-v8-68874a617b5f6b43480f87bf18b681605a2f6f8c.zip |
src: 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/nodejs/node/pull/30829
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
-rw-r--r-- | src/node.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc index 91f07e447f..b44f021084 100644 --- a/src/node.cc +++ b/src/node.cc @@ -108,6 +108,9 @@ #include <unistd.h> // STDIN_FILENO, STDERR_FILENO #endif +#ifdef __PASE__ +#include <sys/ioctl.h> // ioctl +#endif // ========== global C++ headers ========== #include <cerrno> @@ -555,7 +558,14 @@ inline void PlatformInit() { while (s.flags == -1 && errno == EINTR); // NOLINT CHECK_NE(s.flags, -1); +#ifdef __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(fd, TXISATTY + 0x81, nullptr) == -1 && errno == ENOTTY) + continue; +#else if (!isatty(fd)) continue; +#endif s.isatty = true; do |