mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +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:
parent
eb0ad181e9
commit
42272dfbd5
2
cmd.c
2
cmd.c
@ -1298,7 +1298,7 @@ cmd_get_default_path(struct cmd_ctx *ctx, const char *cwd)
|
|||||||
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
|
||||||
root = ctx->cmdclient->cwd;
|
root = ctx->cmdclient->cwd;
|
||||||
else if (ctx->curclient != NULL && s->curw != NULL)
|
else if (ctx->curclient != NULL && s->curw != NULL)
|
||||||
root = get_proc_cwd(s->curw->window->active->pid);
|
root = get_proc_cwd(s->curw->window->active->fd);
|
||||||
else
|
else
|
||||||
return (s->cwd);
|
return (s->cwd);
|
||||||
skip = 0;
|
skip = 0;
|
||||||
|
2
format.c
2
format.c
@ -391,7 +391,7 @@ format_window_pane(struct format_tree *ft, struct window_pane *wp)
|
|||||||
format_add(ft, "pane_start_command", "%s", wp->cmd);
|
format_add(ft, "pane_start_command", "%s", wp->cmd);
|
||||||
if (wp->cwd != NULL)
|
if (wp->cwd != NULL)
|
||||||
format_add(ft, "pane_start_path", "%s", wp->cwd);
|
format_add(ft, "pane_start_path", "%s", wp->cwd);
|
||||||
format_add(ft, "pane_current_path", "%s", get_proc_cwd(wp->pid));
|
format_add(ft, "pane_current_path", "%s", get_proc_cwd(wp->fd));
|
||||||
format_add(ft, "pane_pid", "%ld", (long) wp->pid);
|
format_add(ft, "pane_pid", "%ld", (long) wp->pid);
|
||||||
format_add(ft, "pane_tty", "%s", wp->tty);
|
format_add(ft, "pane_tty", "%s", wp->tty);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
|
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);
|
char *get_proc_cwd(int);
|
||||||
|
|
||||||
struct kinfo_proc *
|
struct kinfo_proc *
|
||||||
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
|
cmp_procs(struct kinfo_proc *p1, struct kinfo_proc *p2)
|
||||||
@ -133,12 +133,14 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
char*
|
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];
|
static char path[MAXPATHLEN];
|
||||||
size_t pathlen = sizeof path;
|
size_t pathlen = sizeof path;
|
||||||
|
|
||||||
|
if ((name[2] = tcgetpgrp(fd)) == -1)
|
||||||
|
return (NULL);
|
||||||
if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
|
if (sysctl(name, 3, path, &pathlen, NULL, 0) != 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
return (path);
|
return (path);
|
||||||
|
2
tmux.h
2
tmux.h
@ -2277,7 +2277,7 @@ u_int utf8_split2(u_int, u_char *);
|
|||||||
|
|
||||||
/* procname.c */
|
/* procname.c */
|
||||||
char *get_proc_name(int, char *);
|
char *get_proc_name(int, char *);
|
||||||
char *get_proc_cwd(pid_t);
|
char *get_proc_cwd(int);
|
||||||
|
|
||||||
/* log.c */
|
/* log.c */
|
||||||
void log_open(int, const char *);
|
void log_open(int, const char *);
|
||||||
|
Loading…
Reference in New Issue
Block a user