Skip to content

Commit 30d2669

Browse files
committed
Cygwin: console: Fix clean up conditions in close()
Previously, the condition to clean up input/output mode was based on wrong premise. This patch fixes that. Fixes: 8ee8b0c ("Cygwin: console: Use GetCurrentProcessId() instead of myself->dwProcessId") Signed-off-by: Takashi Yano <[email protected]>
1 parent 90031ff commit 30d2669

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

winsup/cygwin/fhandler/console.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,16 +1976,16 @@ fhandler_console::close ()
19761976

19771977
acquire_output_mutex (mutex_timeout);
19781978

1979-
if (shared_console_info[unit])
1979+
if (shared_console_info[unit] && !myself->cygstarted
1980+
&& (dev_t) myself->ctty == get_device ())
19801981
{
19811982
/* Restore console mode if this is the last closure. */
19821983
OBJECT_BASIC_INFORMATION obi;
19831984
NTSTATUS status;
19841985
status = NtQueryObject (get_handle (), ObjectBasicInformation,
19851986
&obi, sizeof obi, NULL);
19861987
if (NT_SUCCESS (status)
1987-
&& obi.HandleCount <= (myself->cygstarted ? 2 : 3)
1988-
&& (dev_t) myself->ctty == get_device ())
1988+
&& obi.HandleCount == (con.owner == GetCurrentProcessId () ? 2 : 3))
19891989
{
19901990
/* Cleaning-up console mode for cygwin apps. */
19911991
set_output_mode (tty::restore, &get_ttyp ()->ti, &handle_set);

0 commit comments

Comments
 (0)