diff options
author | 2017-01-13 10:12:12 +0000 | |
---|---|---|
committer | 2017-01-13 10:12:12 +0000 | |
commit | b15f33eca6707a8f53feb3de7d2cc1ef40504d16 (patch) | |
tree | 1f3364f7453c810ad008a76716b9246001eb1115 /usr.bin/tmux/server-client.c | |
parent | Ansify cpu_sysctl() on alpha, arm, arm64, luna88k and sparc64. (diff) | |
download | wireguard-openbsd-b15f33eca6707a8f53feb3de7d2cc1ef40504d16.tar.xz wireguard-openbsd-b15f33eca6707a8f53feb3de7d2cc1ef40504d16.zip |
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.
Diffstat (limited to 'usr.bin/tmux/server-client.c')
-rw-r--r-- | usr.bin/tmux/server-client.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index aa808a2d129..51a89a1b9b8 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.206 2017/01/11 22:36:07 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.207 2017/01/13 10:12:12 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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) |