mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 18:08:51 +00:00
Apple have changed their API again, from Gregory Pakosz.
This commit is contained in:
parent
c6cdab1f79
commit
060515684d
@ -17,7 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
#include <Availability.h>
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
#include <libproc.h>
|
#include <libproc.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -33,18 +35,34 @@ 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)
|
||||||
{
|
{
|
||||||
struct proc_bsdinfo bsdinfo;
|
#ifdef __MAC_10_7
|
||||||
|
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_PIDTBSDINFO, 0,
|
ret = proc_pidinfo(pgrp, PROC_PIDT_SHORTBSDINFO, 0,
|
||||||
&bsdinfo, sizeof bsdinfo);
|
&bsdinfo, sizeof bsdinfo);
|
||||||
if (ret == sizeof bsdinfo && *bsdinfo.pbi_comm != '\0')
|
if (ret == sizeof bsdinfo && *bsdinfo.pbsi_comm != '\0')
|
||||||
return (strdup(bsdinfo.pbi_comm));
|
return (strdup(bsdinfo.pbsi_comm));
|
||||||
|
#else
|
||||||
|
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);
|
return (NULL);
|
||||||
|
|
||||||
|
size = sizeof kp;
|
||||||
|
if (sysctl(mib, 4, &kp, &size, NULL, 0) == -1)
|
||||||
|
return (NULL);
|
||||||
|
if (*kp.kp_proc.p_comm == '\0')
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
return (strdup(kp.kp_proc.p_comm));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
Loading…
Reference in New Issue
Block a user