mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Drop support for popups where the content is provided directly to tmux
(which does not have many practical uses) and only support running a program in the popup. display-popup is now simpler and can accept multiple arguments to avoid escaping problems (like the other commands).
This commit is contained in:
		
							
								
								
									
										46
									
								
								job.c
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								job.c
									
									
									
									
									
								
							@@ -68,19 +68,20 @@ struct job {
 | 
			
		||||
/* All jobs list. */
 | 
			
		||||
static LIST_HEAD(joblist, job) all_jobs = LIST_HEAD_INITIALIZER(all_jobs);
 | 
			
		||||
 | 
			
		||||
/* Start a job running, if it isn't already. */
 | 
			
		||||
/* Start a job running. */
 | 
			
		||||
struct job *
 | 
			
		||||
job_run(const char *cmd, struct session *s, const char *cwd,
 | 
			
		||||
    job_update_cb updatecb, job_complete_cb completecb, job_free_cb freecb,
 | 
			
		||||
    void *data, int flags, int sx, int sy)
 | 
			
		||||
job_run(const char *cmd, int argc, char **argv, struct session *s,
 | 
			
		||||
    const char *cwd, job_update_cb updatecb, job_complete_cb completecb,
 | 
			
		||||
    job_free_cb freecb, void *data, int flags, int sx, int sy)
 | 
			
		||||
{
 | 
			
		||||
	struct job	*job;
 | 
			
		||||
	struct environ	*env;
 | 
			
		||||
	pid_t		 pid;
 | 
			
		||||
	int		 nullfd, out[2], master;
 | 
			
		||||
	const char	*home;
 | 
			
		||||
	sigset_t	 set, oldset;
 | 
			
		||||
	struct winsize	 ws;
 | 
			
		||||
	struct job	 *job;
 | 
			
		||||
	struct environ	 *env;
 | 
			
		||||
	pid_t		  pid;
 | 
			
		||||
	int		  nullfd, out[2], master;
 | 
			
		||||
	const char	 *home;
 | 
			
		||||
	sigset_t	  set, oldset;
 | 
			
		||||
	struct winsize	  ws;
 | 
			
		||||
	char		**argvp;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Do not set TERM during .tmux.conf, it is nice to be able to use
 | 
			
		||||
@@ -101,7 +102,13 @@ job_run(const char *cmd, struct session *s, const char *cwd,
 | 
			
		||||
			goto fail;
 | 
			
		||||
		pid = fork();
 | 
			
		||||
	}
 | 
			
		||||
	log_debug("%s: cmd=%s, cwd=%s", __func__, cmd, cwd == NULL ? "" : cwd);
 | 
			
		||||
	if (cmd == NULL) {
 | 
			
		||||
		cmd_log_argv(argc, argv, "%s:", __func__);
 | 
			
		||||
		log_debug("%s: cwd=%s", __func__, cwd == NULL ? "" : cwd);
 | 
			
		||||
	} else {
 | 
			
		||||
		log_debug("%s: cmd=%s, cwd=%s", __func__, cmd,
 | 
			
		||||
		    cwd == NULL ? "" : cwd);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	switch (pid) {
 | 
			
		||||
	case -1:
 | 
			
		||||
@@ -141,8 +148,14 @@ job_run(const char *cmd, struct session *s, const char *cwd,
 | 
			
		||||
		}
 | 
			
		||||
		closefrom(STDERR_FILENO + 1);
 | 
			
		||||
 | 
			
		||||
		execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
 | 
			
		||||
		fatal("execl failed");
 | 
			
		||||
		if (cmd != NULL) {
 | 
			
		||||
			execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
 | 
			
		||||
			fatal("execl failed");
 | 
			
		||||
		} else {
 | 
			
		||||
			argvp = cmd_copy_argv(argc, argv);
 | 
			
		||||
			execvp(argvp[0], argvp);
 | 
			
		||||
			fatal("execvp failed");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	sigprocmask(SIG_SETMASK, &oldset, NULL);
 | 
			
		||||
@@ -152,7 +165,10 @@ job_run(const char *cmd, struct session *s, const char *cwd,
 | 
			
		||||
	job->state = JOB_RUNNING;
 | 
			
		||||
	job->flags = flags;
 | 
			
		||||
 | 
			
		||||
	job->cmd = xstrdup(cmd);
 | 
			
		||||
	if (cmd != NULL)
 | 
			
		||||
		job->cmd = xstrdup(cmd);
 | 
			
		||||
	else
 | 
			
		||||
		job->cmd = cmd_stringify_argv(argc, argv);
 | 
			
		||||
	job->pid = pid;
 | 
			
		||||
	job->status = 0;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user