Add -E to detach-client to exec a command to replace the client instead

of exiting it, useful if tmux wasn't exec'd itself. From Jenna Magius.
This commit is contained in:
nicm
2017-01-13 10:12:12 +00:00
parent 24cba5907b
commit 95950bf668
5 changed files with 74 additions and 7 deletions

View File

@ -296,6 +296,32 @@ server_client_detach(struct client *c, enum msgtype msgtype)
proc_send_s(c->peer, msgtype, s->name);
}
/* Execute command to replace a client, */
void
server_client_exec(struct client *c, const char *cmd)
{
struct session *s = c->session;
char *msg, *shell;
size_t cmdsize, shellsize;
if (*cmd == '\0')
return;
cmdsize = strlen(cmd) + 1;
if (s != NULL)
shell = options_get_string(s->options, "default-shell");
else
shell = options_get_string(global_s_options, "default-shell");
shellsize = strlen(shell) + 1;
msg = xmalloc(cmdsize + shellsize);
memcpy(msg, cmd, cmdsize);
memcpy(msg + cmdsize, shell, shellsize);
proc_send(c->peer, MSG_EXEC, -1, msg, cmdsize + shellsize);
free(msg);
}
/* Check for mouse keys. */
static key_code
server_client_check_mouse(struct client *c)