Module: wine
Branch: master
Commit: df718b8ab8f0451d026c33d81c1c3cddbed04925
URL: http://source.winehq.org/git/wine.git/?a=commit;h=df718b8ab8f0451d026c33d81…
Author: Andrew Eikum <aeikum(a)codeweavers.com>
Date: Tue Nov 17 09:41:43 2015 -0600
kernel32: Always uninitialize the terminal for the console shell process.
The terminal raw IO check and the console shell process check are used
separately to initialize the terminal in different ways. However, if
either check fails during uninitialization, then no uninitialization
will occur at all and modified terminfo settings will remain instead of
being restored. We should check each condition individually and
uninitialize each part as required.
Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/kernel32/console.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 363e763..51d6e60 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -211,15 +211,18 @@ static BOOL put_console_into_raw_mode(int fd)
static BOOL restore_console_mode(HANDLE hin)
{
int fd;
- BOOL ret;
+ BOOL ret = TRUE;
+
+ if (S_termios_raw)
+ {
+ if ((fd = get_console_bare_fd(hin)) == -1) return FALSE;
+ ret = tcsetattr(fd, TCSANOW, &S_termios) >= 0;
+ close(fd);
+ }
+
+ if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle == KERNEL32_CONSOLE_SHELL)
+ TERM_Exit();
- if (!S_termios_raw ||
- RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != KERNEL32_CONSOLE_SHELL)
- return TRUE;
- if ((fd = get_console_bare_fd(hin)) == -1) return FALSE;
- ret = tcsetattr(fd, TCSANOW, &S_termios) >= 0;
- close(fd);
- TERM_Exit();
return ret;
}