Cygwin: pty: Fix acquiring attach_mutex timing.

- When temporarily attaching a console, the timing of acquiring
  attach_mutex was not appropriate. This sometimes caused master
  forwarding thread to crash on Ctrl-C in Windows 7. This patch
  fixes the issue.
This commit is contained in:
Takashi Yano 2022-05-08 19:45:31 +09:00
parent aa9b5262f2
commit b29fd96cac
1 changed files with 1 additions and 1 deletions

View File

@ -4171,13 +4171,13 @@ DWORD
fhandler_pty_common::attach_console_temporarily (DWORD target_pid)
{
DWORD resume_pid = 0;
acquire_attach_mutex (mutex_timeout);
pinfo pinfo_resume (myself->ppid);
if (pinfo_resume)
resume_pid = pinfo_resume->dwProcessId;
if (!resume_pid)
resume_pid = get_console_process_id (myself->dwProcessId, false);
bool console_exists = fhandler_console::exists ();
acquire_attach_mutex (mutex_timeout);
if (!console_exists || resume_pid)
{
FreeConsole ();