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.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index c5718a380..3cea6b9d0 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -454,6 +454,7 @@ fhandler_tty_slave::open (int flags, mode_t)
else
{
*this = cygheap->ctty;
+ fhandler_console::open_fhs++;
termios_printf ("copied tty fhandler from cygheap");
return 1;
}
@@ -601,7 +602,7 @@ fhandler_tty_slave::close ()
if (!--fhandler_console::open_fhs && myself->ctty == -1)
FreeConsole ();
termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
- if (!exit_state && get_io_handle () == cygheap->ctty.get_io_handle ())
+ if (myself->ctty >= 0 && get_io_handle () == cygheap->ctty.get_io_handle ())
return 1;
return fhandler_tty_common::close ();
}
@@ -1173,6 +1174,8 @@ fhandler_tty_common::close ()
if (!ForceCloseHandle1 (get_output_handle (), to_pty))
termios_printf ("CloseHandle (get_output_handle ()<%p>), %E", get_output_handle ());
+ set_io_handle (NULL);
+
inuse = NULL;
termios_printf ("tty%d <%p,%p> closed", get_unit (), get_handle (), get_output_handle ());
return 0;