mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-13 23:38:52 +02:00
Change the way the working directory for new processes is discovered. If
default-path isn't empty, it is used. Otherwise: 1) If tmux neww is run from the command line, the working directory of the client is used. 2) Otherwise sysctl KERN_PROC_CWD is used to retrieve the current working directory of the process in the active pane. 3) If that fails, the directory where the session was created is used. Support code by Romain Francois, OpenBSD specific bits by me. Note this requires a recent userland and kernel with KERN_PROC_CWD.
This commit is contained in:
15
procname.c
15
procname.c
@ -35,7 +35,8 @@
|
||||
((p)->p_stat == SSTOP || (p)->p_stat == SZOMB || (p)->p_stat == SDEAD)
|
||||
|
||||
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
|
||||
char *get_proc_name(int, char *);
|
||||
char *get_proc_name(int, char *);
|
||||
char *get_proc_cwd(pid_t);
|
||||
|
||||
struct kinfo_proc *
|
||||
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
|
||||
@ -130,3 +131,15 @@ error:
|
||||
free(buf);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char*
|
||||
get_proc_cwd(pid_t pid)
|
||||
{
|
||||
int name[] = { CTL_KERN, KERN_PROC_CWD, (int)pid };
|
||||
static char path[MAXPATHLEN];
|
||||
size_t pathlen = sizeof path;
|
||||
|
||||
if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
|
||||
return (NULL);
|
||||
return (path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user