aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2024-11-08 20:02:35 +0900
committerTakashi Yano <takashi.yano@nifty.ne.jp>2024-11-08 20:23:45 +0900
commit30d266947842fec82cae9a190bc8b5bf2e108cd0 (patch)
tree16e614ecdcc2a05353dc0db8080ce2fc0ef142fe /winsup/cygwin
parent90031ffe916cdee83d377d757010716a0aa15d34 (diff)
downloadnewlib-30d266947842fec82cae9a190bc8b5bf2e108cd0.zip
newlib-30d266947842fec82cae9a190bc8b5bf2e108cd0.tar.gz
newlib-30d266947842fec82cae9a190bc8b5bf2e108cd0.tar.bz2
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: 8ee8b0c974d7 ("Cygwin: console: Use GetCurrentProcessId() instead of myself->dwProcessId") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/fhandler/console.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index 4efba61..2651e49 100644
--- a/winsup/cygwin/fhandler/console.cc
+++ b/winsup/cygwin/fhandler/console.cc
@@ -1976,7 +1976,8 @@ fhandler_console::close ()
acquire_output_mutex (mutex_timeout);
- if (shared_console_info[unit])
+ if (shared_console_info[unit] && !myself->cygstarted
+ && (dev_t) myself->ctty == get_device ())
{
/* Restore console mode if this is the last closure. */
OBJECT_BASIC_INFORMATION obi;
@@ -1984,8 +1985,7 @@ fhandler_console::close ()
status = NtQueryObject (get_handle (), ObjectBasicInformation,
&obi, sizeof obi, NULL);
if (NT_SUCCESS (status)
- && obi.HandleCount <= (myself->cygstarted ? 2 : 3)
- && (dev_t) myself->ctty == get_device ())
+ && obi.HandleCount == (con.owner == GetCurrentProcessId () ? 2 : 3))
{
/* Cleaning-up console mode for cygwin apps. */
set_output_mode (tty::restore, &get_ttyp ()->ti, &handle_set);