From 0ec4bd28dadcf476baf6180af7cf93bea9214f19 Mon Sep 17 00:00:00 2001 From: Tobias Kortkamp Date: Fri, 8 Mar 2019 17:36:23 +0100 Subject: Add support for SpawnNewInstance using linux compat on FreeBSD This fixes opening a new instance in the shell's current working directory. The code currently assumes that there is a Linux compatible procfs mounted on /proc which is not the case on FreeBSD. However linprocfs(5) is often mounted on /compat/linux/proc so we can use that here for the time being. A proper solution would look up the kern.proc.cwd. sysctl instead, but that is not currently easily doable due to missing KERN_PROC_CWD and struct kinfo_file definitions in the libc crate. --- src/event.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/event.rs b/src/event.rs index 75d27d36..cc26bf22 100644 --- a/src/event.rs +++ b/src/event.rs @@ -172,7 +172,11 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { #[cfg(unix)] let args = { - if let Ok(path) = fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID })) { + #[cfg(not(target_os = "freebsd"))] + let proc_prefix = ""; + #[cfg(target_os = "freebsd")] + let proc_prefix = "/compat/linux"; + if let Ok(path) = fs::read_link(format!("{}/proc/{}/cwd", proc_prefix, unsafe { tty::PID })) { vec!["--working-directory".into(), path] } else { Vec::new() -- cgit