From 29b1b2fb5eee4319cdc1464ee377b68f3171dc27 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Sun, 9 Aug 2009 17:48:55 +0000 Subject: 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. --- tmux.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index 69826d35..24085085 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.157 2009-08-09 17:40:17 tcunha Exp $ */ +/* $Id: tmux.c,v 1.158 2009-08-09 17:48:55 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -49,6 +49,7 @@ volatile sig_atomic_t sigusr2; char *cfg_file; struct options global_s_options; /* session options */ struct options global_w_options; /* window options */ +struct environ global_environ; int server_locked; u_int password_failures; @@ -271,7 +272,7 @@ main(int argc, char **argv) struct hdr hdr; struct passwd *pw; struct msg_print_data printdata; - char *s, *path, *label, *home, *cause; + char *s, *path, *label, *home, *cause, **var; char cwd[MAXPATHLEN]; void *buf; size_t len; @@ -329,6 +330,10 @@ main(int argc, char **argv) log_open_tty(debug_level); siginit(); + environ_init(&global_environ); + for (var = environ; *var != NULL; var++) + environ_put(&global_environ, *var); + if (!(flags & IDENTIFY_UTF8)) { /* * If the user has set whichever of LC_ALL, LC_CTYPE or LANG @@ -385,6 +390,7 @@ main(int argc, char **argv) options_set_number(&global_s_options, "status-utf8", 0); options_set_string(&global_s_options, "terminal-overrides", "*88col*:colors=88,*256col*:colors=256"); + options_set_string(&global_s_options, "update-environment", "DISPLAY"); options_set_number(&global_s_options, "visual-activity", 0); options_set_number(&global_s_options, "visual-bell", 0); options_set_number(&global_s_options, "visual-content", 0); @@ -478,10 +484,10 @@ main(int argc, char **argv) } cmdflags &= ~CMD_STARTSERVER; TAILQ_FOREACH(cmd, cmdlist, qentry) { - if (cmd->entry->flags & CMD_STARTSERVER) { + if (cmd->entry->flags & CMD_STARTSERVER) cmdflags |= CMD_STARTSERVER; - break; - } + if (cmd->entry->flags & CMD_SENDENVIRON) + cmdflags |= CMD_SENDENVIRON; } cmd_list_free(cmdlist); } -- cgit