mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-14 15:58:27 +02:00
Use pgrp of pty fd not pid of immediate child when recovering current working
directory (like current process). From Marcel Partap.
This commit is contained in:
@ -61,13 +61,17 @@ osdep_get_name(int fd, unused char *tty)
|
||||
}
|
||||
|
||||
char *
|
||||
osdep_get_cwd(pid_t pid)
|
||||
osdep_get_cwd(int fd)
|
||||
{
|
||||
static char target[MAXPATHLEN + 1];
|
||||
char *path;
|
||||
pid_t pgrp;
|
||||
ssize_t n;
|
||||
|
||||
xasprintf(&path, "/proc/%d/cwd", pid);
|
||||
if ((pgrp = tcgetpgrp(fd)) == -1)
|
||||
return (NULL);
|
||||
|
||||
xasprintf(&path, "/proc/%lld/cwd", (long long) pgrp);
|
||||
n = readlink(path, target, MAXPATHLEN);
|
||||
free(path);
|
||||
if (n > 0) {
|
||||
|
Reference in New Issue
Block a user