Cygwin: pty: Fix handle leak regarding attach_mutex.
- If the process having master pty opened is forked, attach_mutex fails to be closed when master is closed. This patch fixes the issue.
This commit is contained in:
parent
8a09deb1b7
commit
dcd564f65c
|
@ -57,7 +57,7 @@ fhandler_console::console_state NO_COPY *fhandler_console::shared_console_info;
|
||||||
bool NO_COPY fhandler_console::invisible_console;
|
bool NO_COPY fhandler_console::invisible_console;
|
||||||
|
|
||||||
/* Mutex for AttachConsole()/FreeConsole() in fhandler_tty.cc */
|
/* Mutex for AttachConsole()/FreeConsole() in fhandler_tty.cc */
|
||||||
HANDLE NO_COPY attach_mutex;
|
HANDLE attach_mutex;
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
acquire_attach_mutex (DWORD t)
|
acquire_attach_mutex (DWORD t)
|
||||||
|
|
|
@ -57,7 +57,7 @@ struct pipe_reply {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern HANDLE attach_mutex; /* Defined in fhandler_console.cc */
|
extern HANDLE attach_mutex; /* Defined in fhandler_console.cc */
|
||||||
static LONG NO_COPY master_cnt = 0;
|
static LONG master_cnt = 0;
|
||||||
|
|
||||||
inline static bool pcon_pid_alive (DWORD pid);
|
inline static bool pcon_pid_alive (DWORD pid);
|
||||||
|
|
||||||
|
@ -2042,10 +2042,10 @@ fhandler_pty_master::close ()
|
||||||
}
|
}
|
||||||
release_output_mutex ();
|
release_output_mutex ();
|
||||||
master_fwd_thread->terminate_thread ();
|
master_fwd_thread->terminate_thread ();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (InterlockedDecrement (&master_cnt) == 0)
|
if (InterlockedDecrement (&master_cnt) == 0)
|
||||||
CloseHandle (attach_mutex);
|
CloseHandle (attach_mutex);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the last master handle has been closed. If so, set
|
/* Check if the last master handle has been closed. If so, set
|
||||||
input_available_event to wake up potentially waiting slaves. */
|
input_available_event to wake up potentially waiting slaves. */
|
||||||
|
|
Loading…
Reference in New Issue