summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/server-fn.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-01-23 11:03:44 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-01-23 11:03:44 +0000
commit7e53eabddc6979e4f6c798fee98409cafa0e6a25 (patch)
tree877554c66d5900dcd763f49038c660f468261669 /usr.bin/tmux/server-fn.c
parent7e1a400591be74655347d8b7d61e848954408757 (diff)
Set $TMUX without the session when background jobs are run.
Diffstat (limited to 'usr.bin/tmux/server-fn.c')
-rw-r--r--usr.bin/tmux/server-fn.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index 1589cf7daa8..dde93cac0f0 100644
--- a/usr.bin/tmux/server-fn.c
+++ b/usr.bin/tmux/server-fn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-fn.c,v 1.49 2011/01/01 01:12:09 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.50 2011/01/23 11:03:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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