diff options
author | Tiago Cunha <tcunha@gmx.com> | 2011-02-14 23:11:33 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2011-02-14 23:11:33 +0000 |
commit | d0d1c0e486dc13b6e5db93819ca1b634d384f283 (patch) | |
tree | 84a3d6a559cb2cc6e90fb60fde99a3d65891e285 /server-fn.c | |
parent | d37650dc4f10c38579a8d140cac99d4c4411e729 (diff) |
Sync OpenBSD patchset 848:
Set $TMUX without the session when background jobs are run.
Diffstat (limited to 'server-fn.c')
-rw-r--r-- | server-fn.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/server-fn.c b/server-fn.c index fa470e5a..b66d4dc3 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,4 +1,4 @@ -/* $Id: server-fn.c,v 1.118 2011-01-03 23:27:54 tcunha Exp $ */ +/* $Id: server-fn.c,v 1.119 2011-02-14 23:11:33 tcunha 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 |