4 * Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/types.h>
27 char *osdep_get_name(int, char *);
28 char *osdep_get_cwd(int);
29 struct event_base
*osdep_event_init(void);
31 #define unused __attribute__ ((unused))
34 osdep_get_name(int fd
, unused
char *tty
)
36 struct proc_bsdinfo bsdinfo
;
40 if ((pgrp
= tcgetpgrp(fd
)) == -1)
43 ret
= proc_pidinfo(pgrp
, PROC_PIDTBSDINFO
, 0,
44 &bsdinfo
, sizeof bsdinfo
);
45 if (ret
== sizeof bsdinfo
&& *bsdinfo
.pbi_comm
!= '\0')
46 return (strdup(bsdinfo
.pbi_comm
));
53 static char wd
[PATH_MAX
];
54 struct proc_vnodepathinfo pathinfo
;
58 if ((pgrp
= tcgetpgrp(fd
)) == -1)
61 ret
= proc_pidinfo(pgrp
, PROC_PIDVNODEPATHINFO
, 0,
62 &pathinfo
, sizeof pathinfo
);
63 if (ret
== sizeof pathinfo
) {
64 strlcpy(wd
, pathinfo
.pvi_cdir
.vip_path
, sizeof wd
);
71 osdep_event_init(void)
74 * On OS X, kqueue and poll are both completely broken and don't
75 * work on anything except socket file descriptors (yes, really).
77 setenv("EVENT_NOKQUEUE", "1", 1);
78 setenv("EVENT_NOPOLL", "1", 1);
79 return (event_init());