mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		
							
								
								
									
										38
									
								
								cfg.c
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								cfg.c
									
									
									
									
									
								
							@@ -27,10 +27,19 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static char	 *cfg_file;
 | 
					static char		 *cfg_file;
 | 
				
			||||||
int		  cfg_finished;
 | 
					int			  cfg_finished;
 | 
				
			||||||
static char	**cfg_causes;
 | 
					static char		**cfg_causes;
 | 
				
			||||||
static u_int	  cfg_ncauses;
 | 
					static u_int		  cfg_ncauses;
 | 
				
			||||||
 | 
					static struct cmdq_item	 *cfg_item;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static enum cmd_retval
 | 
				
			||||||
 | 
					cfg_client_done(__unused struct cmdq_item *item, __unused void *data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (!cfg_finished)
 | 
				
			||||||
 | 
							return (CMD_RETURN_WAIT);
 | 
				
			||||||
 | 
						return (CMD_RETURN_NORMAL);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static enum cmd_retval
 | 
					static enum cmd_retval
 | 
				
			||||||
cfg_done(__unused struct cmdq_item *item, __unused void *data)
 | 
					cfg_done(__unused struct cmdq_item *item, __unused void *data)
 | 
				
			||||||
@@ -42,6 +51,9 @@ cfg_done(__unused struct cmdq_item *item, __unused void *data)
 | 
				
			|||||||
	if (!RB_EMPTY(&sessions))
 | 
						if (!RB_EMPTY(&sessions))
 | 
				
			||||||
		cfg_show_causes(RB_MIN(sessions, &sessions));
 | 
							cfg_show_causes(RB_MIN(sessions, &sessions));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (cfg_item != NULL)
 | 
				
			||||||
 | 
							cfg_item->flags &= ~CMDQ_WAITING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	status_prompt_load_history();
 | 
						status_prompt_load_history();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (CMD_RETURN_NORMAL);
 | 
						return (CMD_RETURN_NORMAL);
 | 
				
			||||||
@@ -59,12 +71,24 @@ start_cfg(void)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	const char	*home;
 | 
						const char	*home;
 | 
				
			||||||
	int		 quiet = 0;
 | 
						int		 quiet = 0;
 | 
				
			||||||
 | 
						struct client	*c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Note that the configuration files are loaded without a client, so
 | 
						 * Configuration files are loaded without a client, so NULL is passed
 | 
				
			||||||
	 * NULL is passed into load_cfg() which means that commands run in the
 | 
						 * into load_cfg() and commands run in the global queue with
 | 
				
			||||||
	 * global queue and item->client is NULL for all commands.
 | 
						 * item->client NULL.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * However, we must block the initial client (but just the initial
 | 
				
			||||||
 | 
						 * client) so that its command runs after the configuration is loaded.
 | 
				
			||||||
 | 
						 * Because start_cfg() is called so early, we can be sure the client's
 | 
				
			||||||
 | 
						 * command queue is currently empty and our callback will be at the
 | 
				
			||||||
 | 
						 * front - we need to get in before MSG_COMMAND.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
						c = TAILQ_FIRST(&clients);
 | 
				
			||||||
 | 
						if (c != NULL) {
 | 
				
			||||||
 | 
							cfg_item = cmdq_get_callback(cfg_client_done, NULL);
 | 
				
			||||||
 | 
							cmdq_append(c, cfg_item);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	load_cfg(TMUX_CONF, NULL, NULL, 1);
 | 
						load_cfg(TMUX_CONF, NULL, NULL, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -77,7 +77,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
	if (envent != NULL)
 | 
						if (envent != NULL)
 | 
				
			||||||
		path = envent->value;
 | 
							path = envent->value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	env = environ_for_session(s);
 | 
						env = environ_for_session(s, 0);
 | 
				
			||||||
	if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
 | 
						if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
 | 
				
			||||||
	    s->tio, &cause) != 0) {
 | 
						    s->tio, &cause) != 0) {
 | 
				
			||||||
		cmdq_error(item, "respawn pane failed: %s", cause);
 | 
							cmdq_error(item, "respawn pane failed: %s", cause);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,7 +81,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
	if (envent != NULL)
 | 
						if (envent != NULL)
 | 
				
			||||||
		path = envent->value;
 | 
							path = envent->value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	env = environ_for_session(s);
 | 
						env = environ_for_session(s, 0);
 | 
				
			||||||
	if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
 | 
						if (window_pane_spawn(wp, args->argc, args->argv, path, NULL, NULL, env,
 | 
				
			||||||
	    s->tio, &cause) != 0) {
 | 
						    s->tio, &cause) != 0) {
 | 
				
			||||||
		cmdq_error(item, "respawn window failed: %s", cause);
 | 
							cmdq_error(item, "respawn window failed: %s", cause);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -143,7 +143,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
	if (envent != NULL)
 | 
						if (envent != NULL)
 | 
				
			||||||
		path = envent->value;
 | 
							path = envent->value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	env = environ_for_session(s);
 | 
						env = environ_for_session(s, 0);
 | 
				
			||||||
	if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, env,
 | 
						if (window_pane_spawn(new_wp, argc, argv, path, shell, cwd, env,
 | 
				
			||||||
	    s->tio, &cause) != 0) {
 | 
						    s->tio, &cause) != 0) {
 | 
				
			||||||
		environ_free(env);
 | 
							environ_free(env);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -222,7 +222,7 @@ environ_log(struct environ *env, const char *prefix)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Create initial environment for new child. */
 | 
					/* Create initial environment for new child. */
 | 
				
			||||||
struct environ *
 | 
					struct environ *
 | 
				
			||||||
environ_for_session(struct session *s)
 | 
					environ_for_session(struct session *s, int no_TERM)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct environ	*env;
 | 
						struct environ	*env;
 | 
				
			||||||
	const char	*value;
 | 
						const char	*value;
 | 
				
			||||||
@@ -233,8 +233,10 @@ environ_for_session(struct session *s)
 | 
				
			|||||||
	if (s != NULL)
 | 
						if (s != NULL)
 | 
				
			||||||
		environ_copy(s->environ, env);
 | 
							environ_copy(s->environ, env);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	value = options_get_string(global_options, "default-terminal");
 | 
						if (!no_TERM) {
 | 
				
			||||||
	environ_set(env, "TERM", "%s", value);
 | 
							value = options_get_string(global_options, "default-terminal");
 | 
				
			||||||
 | 
							environ_set(env, "TERM", "%s", value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (s != NULL)
 | 
						if (s != NULL)
 | 
				
			||||||
		idx = s->id;
 | 
							idx = s->id;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								job.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								job.c
									
									
									
									
									
								
							@@ -54,7 +54,12 @@ job_run(const char *cmd, struct session *s, const char *cwd,
 | 
				
			|||||||
	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0)
 | 
						if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, out) != 0)
 | 
				
			||||||
		return (NULL);
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	env = environ_for_session(s);
 | 
						/*
 | 
				
			||||||
 | 
						 * Do not set TERM during .tmux.conf, it is nice to be able to use
 | 
				
			||||||
 | 
						 * if-shell to decide on default-terminal based on outside TERM.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						env = environ_for_session(s, !cfg_finished);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (pid = fork()) {
 | 
						switch (pid = fork()) {
 | 
				
			||||||
	case -1:
 | 
						case -1:
 | 
				
			||||||
		environ_free(env);
 | 
							environ_free(env);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -359,7 +359,7 @@ session_new(struct session *s, const char *name, int argc, char **argv,
 | 
				
			|||||||
		shell = _PATH_BSHELL;
 | 
							shell = _PATH_BSHELL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hlimit = options_get_number(s->options, "history-limit");
 | 
						hlimit = options_get_number(s->options, "history-limit");
 | 
				
			||||||
	env = environ_for_session(s);
 | 
						env = environ_for_session(s, 0);
 | 
				
			||||||
	w = window_create_spawn(name, argc, argv, path, shell, cwd, env, s->tio,
 | 
						w = window_create_spawn(name, argc, argv, path, shell, cwd, env, s->tio,
 | 
				
			||||||
	    s->sx, s->sy, hlimit, cause);
 | 
						    s->sx, s->sy, hlimit, cause);
 | 
				
			||||||
	if (w == NULL) {
 | 
						if (w == NULL) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1616,7 +1616,7 @@ void	environ_unset(struct environ *, const char *);
 | 
				
			|||||||
void	environ_update(struct options *, struct environ *, struct environ *);
 | 
					void	environ_update(struct options *, struct environ *, struct environ *);
 | 
				
			||||||
void	environ_push(struct environ *);
 | 
					void	environ_push(struct environ *);
 | 
				
			||||||
void	environ_log(struct environ *, const char *);
 | 
					void	environ_log(struct environ *, const char *);
 | 
				
			||||||
struct environ *environ_for_session(struct session *);
 | 
					struct environ *environ_for_session(struct session *, int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* tty.c */
 | 
					/* tty.c */
 | 
				
			||||||
void	tty_create_log(void);
 | 
					void	tty_create_log(void);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user