diff options
author | Thomas Adam <thomas@xteddy.org> | 2017-03-09 18:01:16 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2017-03-09 18:01:16 +0000 |
commit | c5bdae466e4dad6c185fa5146b11275b6119ff24 (patch) | |
tree | 05536631ebb8c314a3026748c2b20753594cc5af /environ.c | |
parent | fd96ccfd802aec27a4835f7bb2030003b9668e64 (diff) | |
parent | bce1dee0341b3624d927d393fd0f21771660d5ed (diff) | |
download | rtmux-c5bdae466e4dad6c185fa5146b11275b6119ff24.tar.gz rtmux-c5bdae466e4dad6c185fa5146b11275b6119ff24.tar.bz2 rtmux-c5bdae466e4dad6c185fa5146b11275b6119ff24.zip |
Merge branch 'obsd-master'
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); +} |