aboutsummaryrefslogtreecommitdiff
path: root/server-fn.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-08-09 17:48:55 +0000
committerTiago Cunha <tcunha@gmx.com>2009-08-09 17:48:55 +0000
commit29b1b2fb5eee4319cdc1464ee377b68f3171dc27 (patch)
tree724627190ad66e119ec2771c5731e720a70ea3e9 /server-fn.c
parentaf3db9a4fea9c436ff8e6f452a538ba295e1e6fe (diff)
downloadrtmux-29b1b2fb5eee4319cdc1464ee377b68f3171dc27.tar.gz
rtmux-29b1b2fb5eee4319cdc1464ee377b68f3171dc27.tar.bz2
rtmux-29b1b2fb5eee4319cdc1464ee377b68f3171dc27.zip
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 'server-fn.c')
-rw-r--r--server-fn.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/server-fn.c b/server-fn.c
index 30f9de4a..35162c93 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -1,4 +1,4 @@
-/* $Id: server-fn.c,v 1.79 2009-08-09 17:19:18 tcunha Exp $ */
+/* $Id: server-fn.c,v 1.80 2009-08-09 17:48:55 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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