diff options
Diffstat (limited to 'osdep-darwin.c')
-rw-r--r-- | osdep-darwin.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/osdep-darwin.c b/osdep-darwin.c index 9cac1311..b112fa7c 100644 --- a/osdep-darwin.c +++ b/osdep-darwin.c @@ -26,7 +26,7 @@ #include <unistd.h> char *osdep_get_name(int, char *); -char *osdep_get_cwd(pid_t); +char *osdep_get_cwd(int); struct event_base *osdep_event_init(void); #define unused __attribute__ ((unused)) @@ -51,14 +51,18 @@ osdep_get_name(int fd, unused char *tty) } char * -osdep_get_cwd(pid_t pid) +osdep_get_cwd(int fd) { static char wd[PATH_MAX]; struct proc_vnodepathinfo pathinfo; + pid_t pgrp; int ret; + if ((pgrp = tcgetpgrp(fd)) == -1) + return (NULL); + ret = proc_pidinfo( - pid, PROC_PIDVNODEPATHINFO, 0, &pathinfo, sizeof pathinfo); + pgrp, PROC_PIDVNODEPATHINFO, 0, &pathinfo, sizeof pathinfo); if (ret == sizeof pathinfo) { strlcpy(wd, pathinfo.pvi_cdir.vip_path, sizeof wd); return (wd); |