diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 17:48:55 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-08-09 17:48:55 +0000 |
commit | 29b1b2fb5eee4319cdc1464ee377b68f3171dc27 (patch) | |
tree | 724627190ad66e119ec2771c5731e720a70ea3e9 /client.c | |
parent | af3db9a4fea9c436ff8e6f452a538ba295e1e6fe (diff) |
Sync OpenBSD patchset 231:
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 session 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.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.60 2009-08-09 17:43:00 tcunha Exp $ */ +/* $Id: client.c,v 1.61 2009-08-09 17:48:55 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,6 +33,7 @@ #include "tmux.h" +void client_send_environ(struct client_ctx *); void client_handle_winch(struct client_ctx *); int @@ -99,6 +100,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)"); @@ -137,6 +140,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) { @@ -246,8 +262,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: |