Cygwin: pty: Fix reopening slave in push_to_pcon_screenbuffer().
- For programs compiled with -mwindows option, reopening slave is needed in push_to_pcon_screenbuffer(), however, it was not at appropriate place. This causes the problem reported in https://www.cygwin.com/ml/cygwin/2020-01/msg00161.html. This patch fixes the issue.
This commit is contained in:
parent
4e78f8ea16
commit
da4ee7d60b
|
@ -1273,9 +1273,21 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const char *ptr, size_t len)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int retry_count;
|
||||||
|
retry_count = 0;
|
||||||
DWORD dwMode, flags;
|
DWORD dwMode, flags;
|
||||||
flags = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
flags = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||||
GetConsoleMode (get_output_handle (), &dwMode);
|
while (!GetConsoleMode (get_output_handle (), &dwMode))
|
||||||
|
{
|
||||||
|
termios_printf ("GetConsoleMode failed, %E");
|
||||||
|
/* Re-open handles */
|
||||||
|
this->close ();
|
||||||
|
this->open (0, 0);
|
||||||
|
/* Fix pseudo console window size */
|
||||||
|
this->ioctl (TIOCSWINSZ, &get_ttyp ()->winsize);
|
||||||
|
if (++retry_count > 3)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (!(get_ttyp ()->ti.c_oflag & OPOST) ||
|
if (!(get_ttyp ()->ti.c_oflag & OPOST) ||
|
||||||
!(get_ttyp ()->ti.c_oflag & ONLCR))
|
!(get_ttyp ()->ti.c_oflag & ONLCR))
|
||||||
flags |= DISABLE_NEWLINE_AUTO_RETURN;
|
flags |= DISABLE_NEWLINE_AUTO_RETURN;
|
||||||
|
@ -1284,8 +1296,6 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const char *ptr, size_t len)
|
||||||
p = buf;
|
p = buf;
|
||||||
DWORD wLen, written;
|
DWORD wLen, written;
|
||||||
written = 0;
|
written = 0;
|
||||||
int retry_count;
|
|
||||||
retry_count = 0;
|
|
||||||
BOOL (WINAPI *WriteFunc)
|
BOOL (WINAPI *WriteFunc)
|
||||||
(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED);
|
(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED);
|
||||||
WriteFunc = WriteFile_Orig ? WriteFile_Orig : WriteFile;
|
WriteFunc = WriteFile_Orig ? WriteFile_Orig : WriteFile;
|
||||||
|
@ -1294,17 +1304,14 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const char *ptr, size_t len)
|
||||||
if (!WriteFunc (get_output_handle (), p, nlen - written, &wLen, NULL))
|
if (!WriteFunc (get_output_handle (), p, nlen - written, &wLen, NULL))
|
||||||
{
|
{
|
||||||
termios_printf ("WriteFile failed, %E");
|
termios_printf ("WriteFile failed, %E");
|
||||||
this->open (0, 0); /* Re-open handles */
|
|
||||||
/* Fix pseudo console window size */
|
|
||||||
struct winsize win;
|
|
||||||
this->ioctl (TIOCGWINSZ, &win);
|
|
||||||
this->ioctl (TIOCSWINSZ, &win);
|
|
||||||
if (++retry_count > 3)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
written += wLen;
|
written += wLen;
|
||||||
p += wLen;
|
p += wLen;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Detach from pseudo console and resume. */
|
/* Detach from pseudo console and resume. */
|
||||||
flags = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
flags = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||||
SetConsoleMode (get_output_handle (), dwMode | flags);
|
SetConsoleMode (get_output_handle (), dwMode | flags);
|
||||||
|
|
Loading…
Reference in New Issue