mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00: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:
@ -36,7 +36,7 @@
|
||||
|
||||
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
|
||||
char *get_proc_name(int, char *);
|
||||
char *get_proc_cwd(pid_t);
|
||||
char *get_proc_cwd(int);
|
||||
|
||||
struct kinfo_proc *
|
||||
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
|
||||
@ -133,12 +133,14 @@ error:
|
||||
}
|
||||
|
||||
char*
|
||||
get_proc_cwd(pid_t pid)
|
||||
get_proc_cwd(int fd)
|
||||
{
|
||||
int name[] = { CTL_KERN, KERN_PROC_CWD, (int)pid };
|
||||
int name[] = { CTL_KERN, KERN_PROC_CWD, 0 };
|
||||
static char path[MAXPATHLEN];
|
||||
size_t pathlen = sizeof path;
|
||||
|
||||
if ((name[2] = tcgetpgrp(fd)) == -1)
|
||||
return (NULL);
|
||||
if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
|
||||
return (NULL);
|
||||
return (path);
|
||||
|
Reference in New Issue
Block a user