Skip to content

Instantly share code, notes, and snippets.

@ichizok
Created December 7, 2012 06:16
Show Gist options
  • Save ichizok/4231151 to your computer and use it in GitHub Desktop.
Save ichizok/4231151 to your computer and use it in GitHub Desktop.
TMUX 1.7 patch for OSX
diff --git a/osdep-darwin.c b/osdep-darwin.c
index b112fa7..caffe60 100644
--- a/osdep-darwin.c
+++ b/osdep-darwin.c
@@ -16,9 +16,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
#include <event.h>
#include <libproc.h>
#include <stdlib.h>
@@ -34,20 +31,18 @@ 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 *q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment