summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 5b7e69ba5..5483249c9 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -580,21 +580,22 @@ fhandler_tty_slave::open (int flags, mode_t)
&& wincap.pty_needs_alloc_console ())
{
BOOL b;
- HWINSTA horig = GetProcessWindowStation ();
+ HWINSTA h, horig;
+ h = horig = GetProcessWindowStation ();
if (myself->ctty == -1)
{
- HWINSTA h = CreateWindowStation (NULL, 0, GENERIC_READ | GENERIC_WRITE, &sec_none_nih);
+ h = CreateWindowStation (NULL, 0, WINSTA_ALL_ACCESS, &sec_none_nih);
termios_printf ("CreateWindowStation %p, %E", h);
if (h)
{
b = SetProcessWindowStation (h);
termios_printf ("SetProcessWindowStation %d, %E", b);
}
- if (horig)
- CloseWindowStation (horig);
}
b = AllocConsole (); // will cause flashing if workstation
// stuff fails
+ if (horig && h != horig)
+ SetProcessWindowStation (horig);
termios_printf ("%d = AllocConsole (), %E", b);
if (b)
init_console_handler (TRUE);