Skip to content

Commit 6088603

Browse files
dmabupttargos
authored andcommitted
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: #30829 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent e551c16 commit 6088603

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/node.cc

+10
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
#include <unistd.h> // STDIN_FILENO, STDERR_FILENO
109109
#endif
110110

111+
#ifdef __PASE__
112+
#include <sys/ioctl.h> // ioctl
113+
#endif
111114
// ========== global C++ headers ==========
112115

113116
#include <cerrno>
@@ -555,7 +558,14 @@ inline void PlatformInit() {
555558
while (s.flags == -1 && errno == EINTR); // NOLINT
556559
CHECK_NE(s.flags, -1);
557560

561+
#ifdef __PASE__
562+
// On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
563+
// Use ioctl() instead to identify whether it's actually a TTY.
564+
if (ioctl(fd, TXISATTY + 0x81, nullptr) == -1 && errno == ENOTTY)
565+
continue;
566+
#else
558567
if (!isatty(fd)) continue;
568+
#endif
559569
s.isatty = true;
560570

561571
do

0 commit comments

Comments
 (0)