mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -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:
parent
dd756c27fc
commit
d3cfda0371
1 changed files with 19 additions and 5 deletions
|
@ -15,6 +15,7 @@
|
||||||
use super::{Pty, HANDLE};
|
use super::{Pty, HANDLE};
|
||||||
|
|
||||||
use std::i16;
|
use std::i16;
|
||||||
|
use std::io::Error;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::windows::io::IntoRawHandle;
|
use std::os::windows::io::IntoRawHandle;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
@ -155,11 +156,13 @@ pub fn new<'a>(
|
||||||
|
|
||||||
// Create the appropriately sized thread attribute list.
|
// Create the appropriately sized thread attribute list.
|
||||||
unsafe {
|
unsafe {
|
||||||
success =
|
let failure =
|
||||||
InitializeProcThreadAttributeList(ptr::null_mut(), 1, 0, &mut size as PSIZE_T) > 0;
|
InitializeProcThreadAttributeList(ptr::null_mut(), 1, 0, &mut size as PSIZE_T) > 0;
|
||||||
|
|
||||||
// This call was expected to return false.
|
// 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();
|
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,
|
&mut size as PSIZE_T,
|
||||||
) > 0;
|
) > 0;
|
||||||
|
|
||||||
assert!(success);
|
if (!success) {
|
||||||
|
panic_shell_spawn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set thread attribute list's Pseudo Console to the specified ConPTY
|
// Set thread attribute list's Pseudo Console to the specified ConPTY
|
||||||
|
@ -198,7 +203,9 @@ pub fn new<'a>(
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
) > 0;
|
) > 0;
|
||||||
|
|
||||||
assert!(success);
|
if (!success) {
|
||||||
|
panic_shell_spawn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get process commandline
|
// Get process commandline
|
||||||
|
@ -231,7 +238,9 @@ pub fn new<'a>(
|
||||||
&mut proc_info as *mut PROCESS_INFORMATION,
|
&mut proc_info as *mut PROCESS_INFORMATION,
|
||||||
) > 0;
|
) > 0;
|
||||||
|
|
||||||
assert!(success);
|
if (!success) {
|
||||||
|
panic_shell_spawn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store handle to console
|
// 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 {
|
impl OnResize for ConptyHandle {
|
||||||
fn on_resize(&mut self, sizeinfo: &SizeInfo) {
|
fn on_resize(&mut self, sizeinfo: &SizeInfo) {
|
||||||
if let Some(coord) = coord_from_sizeinfo(sizeinfo) {
|
if let Some(coord) = coord_from_sizeinfo(sizeinfo) {
|
||||||
|
|
Loading…
Reference in a new issue