summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Tuñón <camotubi@gmail.com>2019-01-19 08:45:45 -0500
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-01-19 13:45:45 +0000
commit09003f6c30c37cbebc39cc64b8246dfa720ea012 (patch)
tree84b4d8a6bf20db51f39d513ab0cdb54f087264e2 /src
parent8b155960708a0ff551c5fc8ec65d2c3c6d12e1da (diff)
downloadalacritty-09003f6c30c37cbebc39cc64b8246dfa720ea012.tar.gz
alacritty-09003f6c30c37cbebc39cc64b8246dfa720ea012.zip
Fix crash on macOS and BSD with SpawnNewInstance action
Diffstat (limited to 'src')
-rw-r--r--src/event.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/event.rs b/src/event.rs
index 5c6b71d0..c3b5bb2d 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -185,14 +185,17 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn spawn_new_instance(&mut self) {
let alacritty = env::args().next().unwrap();
+
#[cfg(unix)]
- let args = [
- "--working-directory".into(),
- fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID }))
- .expect("shell working directory"),
- ];
+ let args = {
+ if let Ok(path) = fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID })) {
+ vec!["--working-directory".into(), path]
+ } else {
+ Vec::new()
+ }
+ };
#[cfg(not(unix))]
- let args: [&str; 0] = [];
+ let args: Vec<String> = Vec::new();
match start_daemon(&alacritty, &args) {
Ok(_) => debug!("Started new Alacritty process: {} {:?}", alacritty, args),