1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Improve errors for missing shell file on Windows

The ConPTY had a cryptic 'assertion failed: success' error whenever
spawning the shell failed.

This changes the ConPTY assertion to a human-readable error which
clearly states that the file could not be found.

The WinPTY backend has not been fixed yet.

This fixes #2016.
This commit is contained in:
Christian Duerr 2019-04-21 22:44:09 +00:00 committed by GitHub
parent dd756c27fc
commit d3cfda0371
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,7 @@
use super::{Pty, HANDLE};
use std::i16;
use std::io::Error;
use std::mem;
use std::os::windows::io::IntoRawHandle;
use std::ptr;
@ -155,11 +156,13 @@ pub fn new<'a>(
// Create the appropriately sized thread attribute list.
unsafe {
success =
let failure =
InitializeProcThreadAttributeList(ptr::null_mut(), 1, 0, &mut size as PSIZE_T) > 0;
// This call was expected to return false.
assert!(!success);
if (!failure) {
panic_shell_spawn();
}
}
let mut attr_list: Box<[BYTE]> = vec![0; size].into_boxed_slice();
@ -183,7 +186,9 @@ pub fn new<'a>(
&mut size as PSIZE_T,
) > 0;
assert!(success);
if (!success) {
panic_shell_spawn();
}
}
// Set thread attribute list's Pseudo Console to the specified ConPTY
@ -198,7 +203,9 @@ pub fn new<'a>(
ptr::null_mut(),
) > 0;
assert!(success);
if (!success) {
panic_shell_spawn();
}
}
// Get process commandline
@ -231,7 +238,9 @@ pub fn new<'a>(
&mut proc_info as *mut PROCESS_INFORMATION,
) > 0;
assert!(success);
if (!success) {
panic_shell_spawn();
}
}
// Store handle to console
@ -253,6 +262,11 @@ pub fn new<'a>(
})
}
// Panic with the last os error as message
fn panic_shell_spawn() {
panic!("Unable to spawn shell: {}", Error::last_os_error());
}
impl OnResize for ConptyHandle {
fn on_resize(&mut self, sizeinfo: &SizeInfo) {
if let Some(coord) = coord_from_sizeinfo(sizeinfo) {