summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-08 21:52:43 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-08 21:52:43 +0000
commit6491274f60c175b89b02b6e4cd0c59b13717e2ec (patch)
tree615959fa3459ad20491f0fedcfcce5a2940d0186 /client.c
parente9856294408c76f374547d9e74d4292f1b0c1163 (diff)
Infrastructure and commands to manage the environment for processes started
within tmux. There is a global environment, copied from the external environment when the server is started and each sesssion has an (initially empty) session environment which overrides it. New commands set-environment and show-environment manipulate or display the environments. A new session option, update-environment, is a space-separated list of variables which are updated from the external environment into the session environment every time a new session is created - the default is DISPLAY.
Diffstat (limited to 'client.c')
-rw-r--r--client.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/client.c b/client.c
index 829b3d3c..4e756981 100644
--- a/client.c
+++ b/client.c
@@ -33,6 +33,7 @@
#include "tmux.h"
+void client_send_environ(struct client_ctx *);
void client_handle_winch(struct client_ctx *);
int
@@ -95,6 +96,8 @@ server_started:
cctx->srv_in = buffer_create(BUFSIZ);
cctx->srv_out = buffer_create(BUFSIZ);
+ if (cmdflags & CMD_SENDENVIRON)
+ client_send_environ(cctx);
if (isatty(STDIN_FILENO)) {
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
fatal("ioctl(TIOCGWINSZ)");
@@ -133,6 +136,19 @@ not_found:
return (1);
}
+void
+client_send_environ(struct client_ctx *cctx)
+{
+ char **var;
+ struct msg_environ_data data;
+
+ for (var = environ; *var != NULL; var++) {
+ if (strlcpy(data.var, *var, sizeof data.var) >= sizeof data.var)
+ continue;
+ client_write_server(cctx, MSG_ENVIRON, &data, sizeof data);
+ }
+}
+
int
client_main(struct client_ctx *cctx)
{
@@ -242,8 +258,8 @@ client_msg_dispatch(struct client_ctx *cctx)
if (hdr.size != sizeof printdata)
fatalx("bad MSG_PRINT size");
buffer_read(cctx->srv_in, &printdata, sizeof printdata);
- printdata.msg[(sizeof printdata.msg) - 1] = '\0';
+ printdata.msg[(sizeof printdata.msg) - 1] = '\0';
cctx->errstr = xstrdup(printdata.msg);
return (-1);
case MSG_EXIT: