mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-18 09:30:04 +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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user