diff options
Diffstat (limited to 'osdep-sunos.c')
-rw-r--r-- | osdep-sunos.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/osdep-sunos.c b/osdep-sunos.c index bb67412c..fd644f5d 100644 --- a/osdep-sunos.c +++ b/osdep-sunos.c @@ -65,13 +65,17 @@ osdep_get_name(int fd, char *tty) } char * -osdep_get_cwd(pid_t pid) +osdep_get_cwd(int fd) { static char target[MAXPATHLEN + 1]; char *path; ssize_t n; + pid_t pgrp; + + if ((pgrp = tcgetpgrp(fd)) == -1) + return (NULL); - xasprintf(&path, "/proc/%u/path/cwd", (u_int) pid); + xasprintf(&path, "/proc/%u/path/cwd", (u_int) pgrp); n = readlink(path, target, MAXPATHLEN); free(path); if (n > 0) { |