diff options
author | nicm <nicm> | 2017-03-09 17:02:38 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-03-09 17:02:38 +0000 |
commit | dbfee6a468172899759a86c7bf50169053adce45 (patch) | |
tree | 6db1e79cc83501839bb96436a430cce03c1ea730 /environ.c | |
parent | e8f2609ca445b09b04cb131059e5b71c3a40f451 (diff) |
Move server_fill_environ into environ.c and move some other common code
into it.
Diffstat (limited to 'environ.c')
-rw-r--r-- | environ.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -20,6 +20,7 @@ #include <stdlib.h> #include <string.h> +#include <unistd.h> #include "tmux.h" @@ -218,3 +219,28 @@ environ_log(struct environ *env, const char *prefix) } } } + +/* Create initial environment for new child. */ +struct environ * +environ_for_session(struct session *s) +{ + struct environ *env; + const char *value; + int idx; + + env = environ_create(); + environ_copy(global_environ, env); + if (s != NULL) + environ_copy(s->environ, env); + + value = options_get_string(global_options, "default-terminal"); + environ_set(env, "TERM", "%s", value); + + if (s != NULL) + idx = s->id; + else + idx = -1; + environ_set(env, "TMUX", "%s,%ld,%d", socket_path, (long)getpid(), idx); + + return (env); +} |