summaryrefslogtreecommitdiffstats
path: root/server-fn.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 /server-fn.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 'server-fn.c')
-rw-r--r--server-fn.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/server-fn.c b/server-fn.c
index 83ef6ca8..6f6ed2c8 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -26,25 +26,20 @@
int server_lock_callback(void *, const char *);
-const char **
-server_fill_environ(struct session *s)
+void
+server_fill_environ(struct session *s, struct environ *env)
{
- static const char *env[] = { NULL /* TMUX= */, NULL /* TERM */, NULL };
- static char tmuxvar[MAXPATHLEN + 256], termvar[256];
- u_int idx;
+ char tmuxvar[MAXPATHLEN], *term;
+ u_int idx;
if (session_index(s, &idx) != 0)
fatalx("session not found");
-
xsnprintf(tmuxvar, sizeof tmuxvar,
- "TMUX=%s,%ld,%u", socket_path, (long) getpid(), idx);
- env[0] = tmuxvar;
-
- xsnprintf(termvar, sizeof termvar,
- "TERM=%s", options_get_string(&s->options, "default-terminal"));
- env[1] = termvar;
+ "%s,%ld,%u", socket_path, (long) getpid(), idx);
+ environ_set(env, "TMUX", tmuxvar);
- return (env);
+ term = options_get_string(&s->options, "default-terminal");
+ environ_set(env, "TERM", term);
}
void