From b764126a67efdaa403b8bc15d521588b1d38c3f2 Mon Sep 17 00:00:00 2001 From: Limbo Peng Date: Mon, 9 Jul 2012 03:39:12 +0800 Subject: [PATCH] tmux: fixes osdep_get_cwd on Darwin platform Backport of a fix from 1.7 Closes Homebrew/homebrew#13283. Signed-off-by: Adam Vandenberg --- Formula/tmux.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Formula/tmux.rb b/Formula/tmux.rb index a3b8c6d3be0..654b47efb0a 100644 --- a/Formula/tmux.rb +++ b/Formula/tmux.rb @@ -7,6 +7,7 @@ class Tmux < Formula head 'https://tmux.svn.sourceforge.net/svnroot/tmux/trunk' + depends_on 'pkg-config' => :build depends_on 'libevent' if ARGV.build_head? and MacOS.xcode_version >= "4.3" @@ -14,6 +15,14 @@ class Tmux < Formula depends_on "libtool" => :build end + def patches + # This patch adds the implementation of osdep_get_cwd for Darwin platform, + # so that tmux can get current working directory correctly under Mac OS. + # NOTE: it applies to 1.6 only, and should be removed when 1.7 is out. + # (because it has been merged upstream) + DATA + end + def install system "sh", "autogen.sh" if ARGV.build_head? @@ -42,3 +51,32 @@ class Tmux < Formula system "#{bin}/tmux", "-V" end end + +__END__ +diff --git a/osdep-darwin.c b/osdep-darwin.c +index c5820df..7b15446 100644 +--- a/osdep-darwin.c ++++ b/osdep-darwin.c +@@ -18,6 +18,7 @@ + + #include + #include ++#include + + #include + #include +@@ -52,6 +53,15 @@ + char * + osdep_get_cwd(pid_t pid) + { ++ static char wd[PATH_MAX]; ++ struct proc_vnodepathinfo pathinfo; ++ int ret; ++ ++ ret = proc_pidinfo(pid, PROC_PIDVNODEPATHINFO, 0, &pathinfo, sizeof(pathinfo)); ++ if (ret == sizeof(pathinfo)) { ++ strlcpy(wd, pathinfo.pvi_cdir.vip_path, sizeof(wd)); ++ return (wd); ++ } + return (NULL); + }