diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2014-10-02 09:25:15 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2014-10-02 09:25:15 +0100 |
commit | 24d9dc518de6761f645165d49f321b2b56904fb5 (patch) | |
tree | 1ee13af85fae1df751de16ae324f5aeed6440614 /osdep-sunos.c | |
parent | 5e7f1b9f0a5bcff8f9ba410c17de4e822428614c (diff) |
Fix osdep_get_cwd on Solaris 11, from J Raynor.
Diffstat (limited to 'osdep-sunos.c')
-rw-r--r-- | osdep-sunos.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/osdep-sunos.c b/osdep-sunos.c index fd644f5d..d071694e 100644 --- a/osdep-sunos.c +++ b/osdep-sunos.c @@ -69,10 +69,19 @@ osdep_get_cwd(int fd) { static char target[MAXPATHLEN + 1]; char *path; + const char *ttypath; ssize_t n; pid_t pgrp; + int retval, ttyfd; - if ((pgrp = tcgetpgrp(fd)) == -1) + if ((ttypath = ptsname(fd)) == NULL) + return (NULL); + if ((ttyfd = open(ttypath, O_RDONLY|O_NOCTTY)) == -1) + return (NULL); + + retval = ioctl(ttyfd, TIOCGPGRP, &pgrp); + close(ttyfd); + if (retval == -1) return (NULL); xasprintf(&path, "/proc/%u/path/cwd", (u_int) pgrp); |