version 1.16, 2012/07/11 07:10:15 |
version 1.17, 2013/03/24 09:54:10 |
|
|
* Respawn a window (restart the command). Kill existing if -k given. |
* Respawn a window (restart the command). Kill existing if -k given. |
*/ |
*/ |
|
|
enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *); |
enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_q *); |
|
|
const struct cmd_entry cmd_respawn_window_entry = { |
const struct cmd_entry cmd_respawn_window_entry = { |
"respawn-window", "respawnw", |
"respawn-window", "respawnw", |
|
|
}; |
}; |
|
|
enum cmd_retval |
enum cmd_retval |
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct winlink *wl; |
struct winlink *wl; |
|
|
const char *cmd; |
const char *cmd; |
char *cause; |
char *cause; |
|
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL) |
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL) |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
w = wl->window; |
w = wl->window; |
|
|
|
|
TAILQ_FOREACH(wp, &w->panes, entry) { |
TAILQ_FOREACH(wp, &w->panes, entry) { |
if (wp->fd == -1) |
if (wp->fd == -1) |
continue; |
continue; |
ctx->error(ctx, |
cmdq_error(cmdq, |
"window still active: %s:%d", s->name, wl->idx); |
"window still active: %s:%d", s->name, wl->idx); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
else |
else |
cmd = NULL; |
cmd = NULL; |
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { |
if (window_pane_spawn(wp, cmd, NULL, NULL, &env, s->tio, &cause) != 0) { |
ctx->error(ctx, "respawn window failed: %s", cause); |
cmdq_error(cmdq, "respawn window failed: %s", cause); |
free(cause); |
free(cause); |
environ_free(&env); |
environ_free(&env); |
server_destroy_pane(wp); |
server_destroy_pane(wp); |