From 7e6c96d6e1485b52b4243d0cd9699f2063645660 Mon Sep 17 00:00:00 2001 From: Takashi Yano Date: Thu, 16 Jan 2020 20:04:47 +0900 Subject: [PATCH] Cygwin: pty: Fix state mismatch caused in octave gui. - In octave gui, sometimes state mismatch between real pty state and state variable occurs. For example, this occurs when 'ls' command is executed in octave gui. This patch fixes the issue. --- winsup/cygwin/spawn.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 08d52bb28..f7c6dd590 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -947,6 +947,15 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, { FreeConsole (); AttachConsole (pid_restore); + cygheap_fdenum cfd (false); + int fd; + while ((fd = cfd.next ()) >= 0) + if (cfd->get_major () == DEV_PTYS_MAJOR) + { + fhandler_pty_slave *ptys = + (fhandler_pty_slave *) (fhandler_base *) cfd; + ptys->fixup_after_attach (false, fd); + } } return (int) res;