From c1b994852594b23b7443e01e05257c991684ba4e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 9 Dec 2011 16:37:29 +0000 Subject: 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. --- osdep-sunos.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'osdep-sunos.c') diff --git a/osdep-sunos.c b/osdep-sunos.c index 5d1e582e..6ba27691 100644 --- a/osdep-sunos.c +++ b/osdep-sunos.c @@ -64,6 +64,23 @@ osdep_get_name(int fd, char *tty) return (xstrdup(p.pr_fname)); } +char * +osdep_get_cwd(pid_t pid) +{ + static char target[MAXPATHLEN + 1]; + char *path; + ssize_t n; + + xasprintf(&path, "/proc/%u/path/cwd", (u_int) pid); + n = readlink(path, target, MAXPATHLEN); + xfree(path); + if (n > 0) { + target[n] = '\0'; + return (target); + } + return (NULL); +} + struct event_base * osdep_event_init(void) { -- cgit v1.2.3