version 1.21, 2016/10/10 21:51:39 |
version 1.22, 2016/10/16 19:04:05 |
|
|
* Respawn a pane (restart the command). Kill existing if -k given. |
* Respawn a pane (restart the command). Kill existing if -k given. |
*/ |
*/ |
|
|
static enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_q *); |
static enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmdq_item *); |
|
|
const struct cmd_entry cmd_respawn_pane_entry = { |
const struct cmd_entry cmd_respawn_pane_entry = { |
.name = "respawn-pane", |
.name = "respawn-pane", |
|
|
}; |
}; |
|
|
static enum cmd_retval |
static enum cmd_retval |
cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq) |
cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
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 = cmdq->state.tflag.wp; |
struct window_pane *wp = item->state.tflag.wp; |
struct session *s = cmdq->state.tflag.s; |
struct session *s = item->state.tflag.s; |
struct environ *env; |
struct environ *env; |
const char *path; |
const char *path; |
char *cause; |
char *cause; |
|
|
if (!args_has(self->args, 'k') && wp->fd != -1) { |
if (!args_has(self->args, 'k') && wp->fd != -1) { |
if (window_pane_index(wp, &idx) != 0) |
if (window_pane_index(wp, &idx) != 0) |
fatalx("index not found"); |
fatalx("index not found"); |
cmdq_error(cmdq, "pane still active: %s:%d.%u", |
cmdq_error(item, "pane still active: %s:%d.%u", |
s->name, wl->idx, idx); |
s->name, wl->idx, idx); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
input_init(wp); |
input_init(wp); |
|
|
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 pane failed: %s", cause); |
cmdq_error(item, "respawn pane failed: %s", cause); |
free(cause); |
free(cause); |
environ_free(env); |
environ_free(env); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |