The branch, master has been updated
       via  7360ff4496bfd159ac5935a18de675f067c375db (commit)
      from  a6fd92bd8d25727e39ccb360b15fe8730e5e66bb (commit)

- Log -----------------------------------------------------------------
commit 7360ff4496bfd159ac5935a18de675f067c375db
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Use proc_pidinfo on Darwin for process name too, from OZAKI Kiichi.
---
 osdep-darwin.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/osdep-darwin.c b/osdep-darwin.c
index b112fa7..23de9d5 100644
--- a/osdep-darwin.c
+++ b/osdep-darwin.c
@@ -17,7 +17,6 @@
  */
 
 #include <sys/types.h>
-#include <sys/sysctl.h>
 
 #include <event.h>
 #include <libproc.h>
@@ -34,26 +33,24 @@ struct event_base   *osdep_event_init(void);
 char *
 osdep_get_name(int fd, unused char *tty)
 {
-       int     mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, 0 };
-       size_t  size;
-       struct kinfo_proc kp;
-
-       if ((mib[3] = tcgetpgrp(fd)) == -1)
-               return (NULL);
+       struct proc_bsdshortinfo        bsdinfo;
+       pid_t                           pgrp;
+       int                             ret;
 
-       size = sizeof kp;
-       if (sysctl(mib, 4, &kp, &size, NULL, 0) == -1)
-               return (NULL);
-       if (*kp.kp_proc.p_comm == '\0')
+       if ((pgrp = tcgetpgrp(fd)) == -1)
                return (NULL);
 
-       return (strdup(kp.kp_proc.p_comm));
+       ret = proc_pidinfo(pgrp, PROC_PIDT_SHORTBSDINFO, 0,
+           &bsdinfo, sizeof bsdinfo);
+       if (ret == sizeof bsdinfo && *bsdinfo.pbsi_comm != '\0')
+               return (strdup(bsdinfo.pbsi_comm));
+       return (NULL);
 }
 
 char *
 osdep_get_cwd(int fd)
 {
-       static char                     wd[PATH_MAX];
+       static char                     wd[PATH_MAX];
        struct proc_vnodepathinfo       pathinfo;
        pid_t                           pgrp;
        int                             ret;
@@ -61,8 +58,8 @@ osdep_get_cwd(int fd)
        if ((pgrp = tcgetpgrp(fd)) == -1)
                return (NULL);
 
-       ret = proc_pidinfo(
-           pgrp, PROC_PIDVNODEPATHINFO, 0, &pathinfo, sizeof pathinfo);
+       ret = proc_pidinfo(pgrp, PROC_PIDVNODEPATHINFO, 0,
+           &pathinfo, sizeof pathinfo);
        if (ret == sizeof pathinfo) {
                strlcpy(wd, pathinfo.pvi_cdir.vip_path, sizeof wd);
                return (wd);


-----------------------------------------------------------------------

Summary of changes:
 osdep-darwin.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to