};
extern HANDLE attach_mutex; /* Defined in fhandler_console.cc */
+static LONG NO_COPY master_cnt = 0;
inline static bool pcon_pid_alive (DWORD pid);
}
release_output_mutex ();
master_fwd_thread->terminate_thread ();
- CloseHandle (attach_mutex);
+ if (InterlockedDecrement (&master_cnt) == 0)
+ CloseHandle (attach_mutex);
}
}
if (!(pcon_mutex = CreateMutex (&sa, FALSE, buf)))
goto err;
- attach_mutex = CreateMutex (&sa, FALSE, NULL);
+ if (InterlockedIncrement (&master_cnt) == 1)
+ attach_mutex = CreateMutex (&sa, FALSE, NULL);
/* Create master control pipe which allows the master to duplicate
the pty pipe handles to processes which deserve it. */
in ps(1) output.
Addresses: https://cygwin.com/pipermail/cygwin/2021-July/248998.html
https://cygwin.com/pipermail/cygwin/2021-August/249124.html
+
+- Fix pty master closing error regarding attach_mutex.
+ Addresses: https://cygwin.com/pipermail/cygwin-developers/2021-October/012418.html