Fix crash on macOS and BSD with SpawnNewInstance action

This commit is contained in:
Carlos Tuñón 2019-01-19 08:45:45 -05:00 committed by Christian Duerr
parent 8b15596070
commit 09003f6c30
3 changed files with 143 additions and 317 deletions

View File

@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Prevent Alacritty from crashing when started on a system without any free space - Prevent Alacritty from crashing when started on a system without any free space
- Resolve issue with high CPU usage after moving Alacritty between displays - Resolve issue with high CPU usage after moving Alacritty between displays
- Characters will no longer be deleted when using ncurses with the hard tab optimization - Characters will no longer be deleted when using ncurses with the hard tab optimization
- Crash on non-linux operating systems when using the `SpawnNewInstance` action
## Version 0.2.5 ## Version 0.2.5

444
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -185,14 +185,17 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn spawn_new_instance(&mut self) { fn spawn_new_instance(&mut self) {
let alacritty = env::args().next().unwrap(); let alacritty = env::args().next().unwrap();
#[cfg(unix)] #[cfg(unix)]
let args = [ let args = {
"--working-directory".into(), if let Ok(path) = fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID })) {
fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID })) vec!["--working-directory".into(), path]
.expect("shell working directory"), } else {
]; Vec::new()
}
};
#[cfg(not(unix))] #[cfg(not(unix))]
let args: [&str; 0] = []; let args: Vec<String> = Vec::new();
match start_daemon(&alacritty, &args) { match start_daemon(&alacritty, &args) {
Ok(_) => debug!("Started new Alacritty process: {} {:?}", alacritty, args), Ok(_) => debug!("Started new Alacritty process: {} {:?}", alacritty, args),