diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2012-09-24 14:05:38 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2012-09-24 14:05:38 +0100 |
commit | 5d60bc7f7c43c20fcf65531b5a5fb1fc7dcbb338 (patch) | |
tree | fd7cdea8dd53657a1545db7df6f2baa1e1c2f574 /osdep-sunos.c | |
parent | 5b85efeb93d44e504e36ae06a91c2e1b8b82c50e (diff) |
Use pgrp of pty fd not pid of immediate child when recovering current working
directory (like current process). From Marcel Partap.
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) { |