Use proc_bsdinfo which works on older OS X versions, from OZAKI Kiichi.

This commit is contained in:
Nicholas Marriott 2013-04-10 12:46:29 +01:00
parent 3ea893464f
commit 46b3c1a025

View File

@ -18,7 +18,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <Availability.h>
#include <event.h> #include <event.h>
#include <libproc.h> #include <libproc.h>
#include <stdlib.h> #include <stdlib.h>
@ -34,19 +33,17 @@ struct event_base *osdep_event_init(void);
char * char *
osdep_get_name(int fd, unused char *tty) osdep_get_name(int fd, unused char *tty)
{ {
#ifdef __MAC_10_7 struct proc_bsdinfo bsdinfo;
struct proc_bsdshortinfo bsdinfo;
pid_t pgrp; pid_t pgrp;
int ret; int ret;
if ((pgrp = tcgetpgrp(fd)) == -1) if ((pgrp = tcgetpgrp(fd)) == -1)
return (NULL); return (NULL);
ret = proc_pidinfo(pgrp, PROC_PIDT_SHORTBSDINFO, 0, ret = proc_pidinfo(pgrp, PROC_PIDTBSDINFO, 0,
&bsdinfo, sizeof bsdinfo); &bsdinfo, sizeof bsdinfo);
if (ret == sizeof bsdinfo && *bsdinfo.pbsi_comm != '\0') if (ret == sizeof bsdinfo && *bsdinfo.pbi_comm != '\0')
return (strdup(bsdinfo.pbsi_comm)); return (strdup(bsdinfo.pbi_comm));
#endif
return (NULL); return (NULL);
} }