summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibuv/src/unix/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmlibuv/src/unix/tty.c')
-rw-r--r--Utilities/cmlibuv/src/unix/tty.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/Utilities/cmlibuv/src/unix/tty.c b/Utilities/cmlibuv/src/unix/tty.c
index db479d6..82cd723 100644
--- a/Utilities/cmlibuv/src/unix/tty.c
+++ b/Utilities/cmlibuv/src/unix/tty.c
@@ -34,6 +34,34 @@
#define IMAXBEL 0
#endif
+#if defined(__PASE__)
+/* On IBM i PASE, for better compatibility with running interactive programs in
+ * a 5250 environment, isatty() will return true for the stdin/stdout/stderr
+ * streams created by QSH/QP2TERM.
+ *
+ * For more, see docs on PASE_STDIO_ISATTY in
+ * https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/apis/pase_environ.htm
+ *
+ * This behavior causes problems for Node as it expects that if isatty() returns
+ * true that TTY ioctls will be supported by that fd (which is not an
+ * unreasonable expectation) and when they don't it crashes with assertion
+ * errors.
+ *
+ * Here, we create our own version of isatty() that uses ioctl() to identify
+ * whether the fd is *really* a TTY or not.
+ */
+static int isreallyatty(int file) {
+ int rc;
+
+ rc = !ioctl(file, TXISATTY + 0x81, NULL);
+ if (!rc && errno != EBADF)
+ errno = ENOTTY;
+
+ return rc;
+}
+#define isatty(fd) isreallyatty(fd)
+#endif
+
static int orig_termios_fd = -1;
static struct termios orig_termios;
static uv_spinlock_t termios_spinlock = UV_SPINLOCK_INITIALIZER;
@@ -136,7 +164,7 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int unused) {
* slave device.
*/
if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0)
- r = uv__open_cloexec(path, mode);
+ r = uv__open_cloexec(path, mode | O_NOCTTY);
else
r = -1;
@@ -362,3 +390,10 @@ int uv_tty_reset_mode(void) {
return err;
}
+
+void uv_tty_set_vterm_state(uv_tty_vtermstate_t state) {
+}
+
+int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state) {
+ return UV_ENOTSUP;
+}