diff options
author | David Hewitt <1939362+davidhewitt@users.noreply.github.com> | 2019-12-12 15:01:23 +0000 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2019-12-12 16:01:23 +0100 |
commit | 6deb274b8283b1d5afe0666d21d6093c89a0835d (patch) | |
tree | 9176379f26570d05daf4ca0508358c1d31cb3d3c /alacritty_terminal | |
parent | 4d3f6de41a4bb999c8941cab2962a2cb5fb91393 (diff) | |
download | alacritty-6deb274b8283b1d5afe0666d21d6093c89a0835d.tar.gz alacritty-6deb274b8283b1d5afe0666d21d6093c89a0835d.zip |
Fix deadlock when closing on Windows using Conpty
Fixes #3042.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/tty/windows/conpty.rs | 4 | ||||
-rw-r--r-- | alacritty_terminal/src/tty/windows/mod.rs | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/alacritty_terminal/src/tty/windows/conpty.rs b/alacritty_terminal/src/tty/windows/conpty.rs index 31f4c252..a1c7edfd 100644 --- a/alacritty_terminal/src/tty/windows/conpty.rs +++ b/alacritty_terminal/src/tty/windows/conpty.rs @@ -90,6 +90,10 @@ pub type ConptyHandle = Arc<Conpty>; impl Drop for Conpty { fn drop(&mut self) { + // XXX: This will block until the conout pipe is drained. Will cause a deadlock if the + // conout pipe has already been dropped by this point. + // + // See PR #3084 and https://docs.microsoft.com/en-us/windows/console/closepseudoconsole unsafe { (self.api.ClosePseudoConsole)(self.handle) } } } diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs index c9c0be73..e112d305 100644 --- a/alacritty_terminal/src/tty/windows/mod.rs +++ b/alacritty_terminal/src/tty/windows/mod.rs @@ -45,6 +45,8 @@ pub enum PtyHandle { } pub struct Pty { + // XXX: Handle is required to be the first field, to ensure correct drop order. Dropping + // `conout` before `handle` will cause a deadlock. handle: PtyHandle, // TODO: It's on the roadmap for the Conpty API to support Overlapped I/O. // See https://github.com/Microsoft/console/issues/262 |