From b84a067e0f004e960dc743813ed3e41987149df4 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Mon, 16 Mar 2026 22:48:50 -0300 Subject: [PATCH] unix,tty: don't drain when setting the TTY mode (#4945) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids a blocking syscall (essentially a write)–and thus potential deadlock–in the asynchronous IO path. --- src/unix/tty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/tty.c b/src/unix/tty.c index b86107202..ae7367933 100644 --- a/src/unix/tty.c +++ b/src/unix/tty.c @@ -52,7 +52,7 @@ */ static int isreallyatty(int file) { int rc; - + rc = !ioctl(file, TXISATTY + 0x81, NULL); if (!rc && errno != EBADF) errno = ENOTTY; @@ -333,8 +333,8 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { UNREACHABLE(); } - /* Apply changes after draining */ - rc = uv__tcsetattr(fd, TCSADRAIN, &tmp); + /* Apply changes now, to avoid blocking. */ + rc = uv__tcsetattr(fd, TCSANOW, &tmp); if (rc == 0) tty->mode = mode;