version 1.31, 2016/10/10 21:51:39 |
version 1.32, 2016/10/16 19:04:05 |
|
|
* Respawn a window (restart the command). Kill existing if -k given. |
* Respawn a window (restart the command). Kill existing if -k given. |
*/ |
*/ |
|
|
static enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_q *); |
static enum cmd_retval cmd_respawn_window_exec(struct cmd *, |
|
struct cmdq_item *); |
|
|
const struct cmd_entry cmd_respawn_window_entry = { |
const struct cmd_entry cmd_respawn_window_entry = { |
.name = "respawn-window", |
.name = "respawn-window", |
|
|
}; |
}; |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct session *s = cmdq->state.tflag.s; |
struct session *s = item->state.tflag.s; |
struct winlink *wl = cmdq->state.tflag.wl; |
struct winlink *wl = item->state.tflag.wl; |
struct window *w = wl->window; |
struct window *w = wl->window; |
struct window_pane *wp; |
struct window_pane *wp; |
struct environ *env; |
struct environ *env; |
|
|
TAILQ_FOREACH(wp, &w->panes, entry) { |
TAILQ_FOREACH(wp, &w->panes, entry) { |
if (wp->fd == -1) |
if (wp->fd == -1) |
continue; |
continue; |
cmdq_error(cmdq, "window still active: %s:%d", s->name, |
cmdq_error(item, "window still active: %s:%d", s->name, |
wl->idx); |
wl->idx); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
window_pane_resize(wp, w->sx, w->sy); |
window_pane_resize(wp, w->sx, w->sy); |
|
|
path = NULL; |
path = NULL; |
if (cmdq->client != NULL && cmdq->client->session == NULL) |
if (item->client != NULL && item->client->session == NULL) |
envent = environ_find(cmdq->client->environ, "PATH"); |
envent = environ_find(item->client->environ, "PATH"); |
else |
else |
envent = environ_find(s->environ, "PATH"); |
envent = environ_find(s->environ, "PATH"); |
if (envent != NULL) |
if (envent != NULL) |
|
|
|
|
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env, |
if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env, |
s->tio, &cause) != 0) { |
s->tio, &cause) != 0) { |
cmdq_error(cmdq, "respawn window failed: %s", cause); |
cmdq_error(item, "respawn window failed: %s", cause); |
free(cause); |
free(cause); |
environ_free(env); |
environ_free(env); |
server_destroy_pane(wp, 0); |
server_destroy_pane(wp, 0); |