mirror of
https://github.com/tmux/tmux.git
synced 2025-03-25 15:28:49 +00:00
Set up working directory before killing the existing pane on respawn.
This commit is contained in:
parent
24350879cd
commit
32816eaebd
35
spawn.c
35
spawn.c
@ -225,6 +225,17 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
|
|
||||||
spawn_log(__func__, sc);
|
spawn_log(__func__, sc);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Work out the current working directory. If respawning, use
|
||||||
|
* the pane's stored one unless specified.
|
||||||
|
*/
|
||||||
|
if (sc->cwd != NULL)
|
||||||
|
cwd = format_single(item, sc->cwd, c, s, NULL, NULL);
|
||||||
|
else if (~sc->flags & SPAWN_RESPAWN)
|
||||||
|
cwd = xstrdup(server_client_get_cwd(c, s));
|
||||||
|
else
|
||||||
|
cwd = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we are respawning then get rid of the old process. Otherwise
|
* If we are respawning then get rid of the old process. Otherwise
|
||||||
* either create a new cell or assign to the one we are given.
|
* either create a new cell or assign to the one we are given.
|
||||||
@ -235,6 +246,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
window_pane_index(sc->wp0, &idx);
|
window_pane_index(sc->wp0, &idx);
|
||||||
xasprintf(cause, "pane %s:%d.%u still active",
|
xasprintf(cause, "pane %s:%d.%u still active",
|
||||||
s->name, sc->wl->idx, idx);
|
s->name, sc->wl->idx, idx);
|
||||||
|
free(cwd);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (sc->wp0->fd != -1) {
|
if (sc->wp0->fd != -1) {
|
||||||
@ -255,8 +267,8 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we have a pane with nothing running in it ready for the new
|
* Now we have a pane with nothing running in it ready for the new process.
|
||||||
* process. Work out the command and arguments.
|
* Work out the command and arguments and store the working directory.
|
||||||
*/
|
*/
|
||||||
if (sc->argc == 0 && (~sc->flags & SPAWN_RESPAWN)) {
|
if (sc->argc == 0 && (~sc->flags & SPAWN_RESPAWN)) {
|
||||||
cmd = options_get_string(s->options, "default-command");
|
cmd = options_get_string(s->options, "default-command");
|
||||||
@ -271,6 +283,10 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
argc = sc->argc;
|
argc = sc->argc;
|
||||||
argv = sc->argv;
|
argv = sc->argv;
|
||||||
}
|
}
|
||||||
|
if (cwd != NULL) {
|
||||||
|
free(new_wp->cwd);
|
||||||
|
new_wp->cwd = cwd;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replace the stored arguments if there are new ones. If not, the
|
* Replace the stored arguments if there are new ones. If not, the
|
||||||
@ -282,21 +298,6 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
new_wp->argv = cmd_copy_argv(argc, argv);
|
new_wp->argv = cmd_copy_argv(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Work out the current working directory. If respawning, use
|
|
||||||
* the pane's stored one unless specified.
|
|
||||||
*/
|
|
||||||
if (sc->cwd != NULL)
|
|
||||||
cwd = format_single(item, sc->cwd, c, s, NULL, NULL);
|
|
||||||
else if (~sc->flags & SPAWN_RESPAWN)
|
|
||||||
cwd = xstrdup(server_client_get_cwd(c, s));
|
|
||||||
else
|
|
||||||
cwd = NULL;
|
|
||||||
if (cwd != NULL) {
|
|
||||||
free(new_wp->cwd);
|
|
||||||
new_wp->cwd = cwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create an environment for this pane. */
|
/* Create an environment for this pane. */
|
||||||
child = environ_for_session(s, 0);
|
child = environ_for_session(s, 0);
|
||||||
if (sc->environ != NULL)
|
if (sc->environ != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user