summaryrefslogtreecommitdiffstats
path: root/cmd-respawn-window.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-08-09 17:48:55 +0000
committerTiago Cunha <tcunha@gmx.com>2009-08-09 17:48:55 +0000
commit29b1b2fb5eee4319cdc1464ee377b68f3171dc27 (patch)
tree724627190ad66e119ec2771c5731e720a70ea3e9 /cmd-respawn-window.c
parentaf3db9a4fea9c436ff8e6f452a538ba295e1e6fe (diff)
Sync OpenBSD patchset 231:
Infrastructure and commands to manage the environment for processes started within tmux. There is a global environment, copied from the external environment when the server is started and each session has an (initially empty) session environment which overrides it. New commands set-environment and show-environment manipulate or display the environments. A new session option, update-environment, is a space-separated list of variables which are updated from the external environment into the session environment every time a new session is created - the default is DISPLAY.
Diffstat (limited to 'cmd-respawn-window.c')
-rw-r--r--cmd-respawn-window.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c
index 0bda1068..c5888c51 100644
--- a/cmd-respawn-window.c
+++ b/cmd-respawn-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-respawn-window.c,v 1.18 2009-07-28 22:12:16 tcunha Exp $ */
+/* $Id: cmd-respawn-window.c,v 1.19 2009-08-09 17:48:55 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -47,7 +47,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
struct window *w;
struct window_pane *wp;
struct session *s;
- const char **env;
+ struct environ env;
char *cause;
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
@@ -64,7 +64,10 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
}
}
- env = server_fill_environ(s);
+ environ_init(&env);
+ environ_copy(&global_environ, &env);
+ environ_copy(&s->environ, &env);
+ server_fill_environ(s, &env);
wp = TAILQ_FIRST(&w->panes);
TAILQ_REMOVE(&w->panes, wp, entry);
@@ -72,9 +75,10 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
window_destroy_panes(w);
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
window_pane_resize(wp, w->sx, w->sy);
- if (window_pane_spawn(wp, data->arg, NULL, env, &cause) != 0) {
+ if (window_pane_spawn(wp, data->arg, NULL, &env, &cause) != 0) {
ctx->error(ctx, "respawn window failed: %s", cause);
xfree(cause);
+ environ_free(&env);
return (-1);
}
layout_init(w);
@@ -84,5 +88,6 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
recalculate_sizes();
server_redraw_window(w);
+ environ_free(&env);
return (0);
}