Skip to content

Commit

Permalink
Cygwin: console Add comment for the recent change
Browse files Browse the repository at this point in the history
Fixes: 30d2669 ("Cygwin: console: Fix clean up conditions in close()")
Suggested-by: Brian Inglis <[email protected]>
Signed-off-by: Takashi Yano <[email protected]>
  • Loading branch information
tyan0 committed Nov 11, 2024
1 parent 6876520 commit 87cd4f3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions winsup/cygwin/fhandler/console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,15 @@ fhandler_console::close ()
NTSTATUS status;
status = NtQueryObject (get_handle (), ObjectBasicInformation,
&obi, sizeof obi, NULL);
/* If the process is not myself->cygstarted and is the console owner,
the process is the last process on this console device. The console
owner has two console handles, i.e. one is io_handle and the other
is the dupplicated handle for cons_master_thread.
If myself->cygstarted is false and the process is not console owner,
the process is supposed to be started by the exec command in the
owner shell. In this case, the owner process is still alive in the
background and waiting for this process. So the handle count is
three (two in the owner process, one is mine). */
if (NT_SUCCESS (status)
&& obi.HandleCount == (con.owner == GetCurrentProcessId () ? 2 : 3))
{
Expand Down

0 comments on commit 87cd4f3

Please sign in to comment.