Skip to content

Commit 1743738

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 50afd34 commit 1743738

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
@@ -97,6 +97,9 @@
9797
#include <unistd.h> // STDIN_FILENO, STDERR_FILENO
9898
#endif
9999

100+
#ifdef __PASE__
101+
#include <sys/ioctl.h> // ioctl
102+
#endif
100103
// ========== global C++ headers ==========
101104

102105
#include <cerrno>
@@ -521,7 +524,14 @@ inline void PlatformInit() {
521524
while (s.flags == -1 && errno == EINTR); // NOLINT
522525
CHECK_NE(s.flags, -1);
523526

527+
#ifdef __PASE__
528+
// On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
529+
// Use ioctl() instead to identify whether it's actually a TTY.
530+
if (ioctl(fd, TXISATTY + 0x81, nullptr) == -1 && errno == ENOTTY)
531+
continue;
532+
#else
524533
if (!isatty(fd)) continue;
534+
#endif
525535
s.isatty = true;
526536

527537
do

0 commit comments

Comments
 (0)