alacritty

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit d3cfda03715c6a644048995afdffdb085984585a
parent dd756c27fc51fd2be1af893b41b10b618ffa83ce
Author: Christian Duerr <chrisduerr@users.noreply.github.com>
Date:   Sun, 21 Apr 2019 22:44:09 +0000

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.

Diffstat:
Msrc/tty/windows/conpty.rs | 24+++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/tty/windows/conpty.rs b/src/tty/windows/conpty.rs @@ -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) {