mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Sort out stdout before stdin/stderr in case the stdout side of the pipe got one
of their fds.
This commit is contained in:
		
							
								
								
									
										12
									
								
								job.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								job.c
									
									
									
									
									
								
							@@ -153,6 +153,12 @@ job_run(struct job *job)
 | 
			
		||||
		sigreset();
 | 
			
		||||
		/* XXX environ? */
 | 
			
		||||
 | 
			
		||||
		close(out[1]);
 | 
			
		||||
		if (dup2(out[0], STDOUT_FILENO) == -1)
 | 
			
		||||
			fatal("dup2 failed");
 | 
			
		||||
		if (out[0] != STDOUT_FILENO)
 | 
			
		||||
			close(out[0]);
 | 
			
		||||
 | 
			
		||||
		nullfd = open(_PATH_DEVNULL, O_RDONLY, 0);
 | 
			
		||||
		if (nullfd < 0)
 | 
			
		||||
			fatal("open failed");
 | 
			
		||||
@@ -163,12 +169,6 @@ job_run(struct job *job)
 | 
			
		||||
		if (nullfd != STDIN_FILENO && nullfd != STDERR_FILENO)
 | 
			
		||||
			close(nullfd);
 | 
			
		||||
 | 
			
		||||
		close(out[1]);
 | 
			
		||||
		if (dup2(out[0], STDOUT_FILENO) == -1)
 | 
			
		||||
			fatal("dup2 failed");
 | 
			
		||||
		if (out[0] != STDOUT_FILENO)
 | 
			
		||||
			close(out[0]);
 | 
			
		||||
 | 
			
		||||
		execl(_PATH_BSHELL, "sh", "-c", job->cmd, (char *) NULL);
 | 
			
		||||
		fatal("execl failed");
 | 
			
		||||
	default:	/* parent */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user