mirror of
https://github.com/alacritty/alacritty.git
synced 2025-08-14 22:22:19 -04:00
Fix panic on exit with ConPTY
Even though the `ClosePseudoConsole` API does not have a return value, it was incorrectly queried by the `Drop` implementation for the ConPTY, leading to a panic on exit. The definition of this call has been updated to match the actual function signatures, which resolve this problem.
This commit is contained in:
parent
66b3f4c877
commit
14e3a0ae5a
2 changed files with 9 additions and 16 deletions
|
@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix panic which could occur when quitting Alacritty on Windows if using the Conpty backend
|
||||||
|
|
||||||
## Version 0.2.9
|
## Version 0.2.9
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use super::{process_should_exit, Pty, HANDLE};
|
use super::{Pty, HANDLE};
|
||||||
|
|
||||||
use std::i16;
|
use std::i16;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -56,7 +56,7 @@ struct ConptyApi {
|
||||||
CreatePseudoConsole:
|
CreatePseudoConsole:
|
||||||
unsafe extern "system" fn(COORD, HANDLE, HANDLE, DWORD, *mut HPCON) -> HRESULT,
|
unsafe extern "system" fn(COORD, HANDLE, HANDLE, DWORD, *mut HPCON) -> HRESULT,
|
||||||
ResizePseudoConsole: unsafe extern "system" fn(HPCON, COORD) -> HRESULT,
|
ResizePseudoConsole: unsafe extern "system" fn(HPCON, COORD) -> HRESULT,
|
||||||
ClosePseudoConsole: unsafe extern "system" fn(HPCON) -> HRESULT,
|
ClosePseudoConsole: unsafe extern "system" fn(HPCON),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConptyApi {
|
impl ConptyApi {
|
||||||
|
@ -95,20 +95,7 @@ pub type ConptyHandle = Arc<Conpty>;
|
||||||
|
|
||||||
impl Drop for Conpty {
|
impl Drop for Conpty {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// The pseusdoconsole might already have been closed by the console process exiting.
|
unsafe { (self.api.ClosePseudoConsole)(self.handle) }
|
||||||
// ClosePseudoConsole will fail with error code 1 in that case.
|
|
||||||
//
|
|
||||||
// This check should be sufficient to avoid that.
|
|
||||||
if !process_should_exit() {
|
|
||||||
let result = unsafe { (self.api.ClosePseudoConsole)(self.handle) };
|
|
||||||
|
|
||||||
// As noted above, if the pseudoconsole is already closed then
|
|
||||||
// ClosePseudoConsole will fail with the error code 1.
|
|
||||||
// (This was not in the MSDN docs as of Nov 2018.)
|
|
||||||
//
|
|
||||||
// If ClosePseudoConsole is successful then result is S_OK.
|
|
||||||
assert!(result == S_OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue