aboutsummaryrefslogtreecommitdiff
path: root/server-fn.c
diff options
context:
space:
mode:
Diffstat (limited to 'server-fn.c')
-rw-r--r--server-fn.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/server-fn.c b/server-fn.c
index 7064c1ed..002d56ac 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -30,14 +30,20 @@ void server_callback_identify(int, short, void *);
void
server_fill_environ(struct session *s, struct environ *env)
{
- char tmuxvar[MAXPATHLEN], *term;
-
- xsnprintf(tmuxvar, sizeof tmuxvar,
- "%s,%ld,%u", socket_path, (long) getpid(), s->idx);
- environ_set(env, "TMUX", tmuxvar);
-
- term = options_get_string(&s->options, "default-terminal");
- environ_set(env, "TERM", term);
+ char var[MAXPATHLEN], *term;
+ u_int idx;
+ long pid;
+
+ if (s != NULL) {
+ term = options_get_string(&s->options, "default-terminal");
+ environ_set(env, "TERM", term);
+
+ idx = s->idx;
+ } else
+ idx = -1;
+ pid = getpid();
+ xsnprintf(var, sizeof var, "%s,%ld,%d", socket_path, pid, idx);
+ environ_set(env, "TMUX", var);
}
void