unix,tty: don't drain when setting the TTY mode (#4945)

This avoids a blocking syscall (essentially a write)–and thus potential
deadlock–in the asynchronous IO path.
This commit is contained in:
Gabriel Baraldi 2026-03-16 22:48:50 -03:00 committed by GitHub
parent 651f2fc161
commit b84a067e0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,7 +52,7 @@
*/ */
static int isreallyatty(int file) { static int isreallyatty(int file) {
int rc; int rc;
rc = !ioctl(file, TXISATTY + 0x81, NULL); rc = !ioctl(file, TXISATTY + 0x81, NULL);
if (!rc && errno != EBADF) if (!rc && errno != EBADF)
errno = ENOTTY; errno = ENOTTY;
@ -333,8 +333,8 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
UNREACHABLE(); UNREACHABLE();
} }
/* Apply changes after draining */ /* Apply changes now, to avoid blocking. */
rc = uv__tcsetattr(fd, TCSADRAIN, &tmp); rc = uv__tcsetattr(fd, TCSANOW, &tmp);
if (rc == 0) if (rc == 0)
tty->mode = mode; tty->mode = mode;