summaryrefslogtreecommitdiffstats
path: root/osdep-openbsd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2011-12-09 16:37:29 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2011-12-09 16:37:29 +0000
commitc1b994852594b23b7443e01e05257c991684ba4e (patch)
tree7cbfc1dbdeff8197e63167dee96200d122a1be72 /osdep-openbsd.c
parent76862acf3e8ebd3573c1b9415b32731891e5545a (diff)
Change the way the working directory for new processes is discovered. If
default-path isn't empty, it is used. Otherwise: 1) If tmux neww is run from the command line, the working directory of the client is used. 2) Otherwise use some platform specific code to retrieve the current working directory of the process in the active pane. 3) If that fails, the directory where the session was created is used. Idea and support code, Linux, Solaris, FreeBSD bits by Romain Francoise, OpenBSD bits by me.
Diffstat (limited to 'osdep-openbsd.c')
-rw-r--r--osdep-openbsd.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/osdep-openbsd.c b/osdep-openbsd.c
index 9eefc44f..4fb75bff 100644
--- a/osdep-openbsd.c
+++ b/osdep-openbsd.c
@@ -37,6 +37,7 @@
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
char *osdep_get_name(int, char *);
+char *osdep_get_cwd(pid_t);
struct event_base *osdep_event_init(void);
struct kinfo_proc *
@@ -133,6 +134,18 @@ error:
return (NULL);
}
+char*
+osdep_get_cwd(pid_t pid)
+{
+ int name[] = { CTL_KERN, KERN_PROC_CWD, (int)pid };
+ static char path[MAXPATHLEN];
+ size_t pathlen = sizeof path;
+
+ if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
+ return (NULL);
+ return (path);
+}
+
struct event_base *
osdep_event_init(void)
{