mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Make stdio blocking again before calling shell command with -c.
This commit is contained in:
		
							
								
								
									
										8
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								tmux.c
									
									
									
									
									
								
							@@ -22,6 +22,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <event.h>
 | 
					#include <event.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
#include <paths.h>
 | 
					#include <paths.h>
 | 
				
			||||||
#include <pwd.h>
 | 
					#include <pwd.h>
 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
@@ -211,6 +212,7 @@ shell_exec(const char *shell, const char *shellcmd)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	const char	*shellname, *ptr;
 | 
						const char	*shellname, *ptr;
 | 
				
			||||||
	char		*argv0;
 | 
						char		*argv0;
 | 
				
			||||||
 | 
						int		 mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ptr = strrchr(shell, '/');
 | 
						ptr = strrchr(shell, '/');
 | 
				
			||||||
	if (ptr != NULL && *(ptr + 1) != '\0')
 | 
						if (ptr != NULL && *(ptr + 1) != '\0')
 | 
				
			||||||
@@ -223,6 +225,12 @@ shell_exec(const char *shell, const char *shellcmd)
 | 
				
			|||||||
		xasprintf(&argv0, "%s", shellname);
 | 
							xasprintf(&argv0, "%s", shellname);
 | 
				
			||||||
	setenv("SHELL", shell, 1);
 | 
						setenv("SHELL", shell, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((mode = fcntl(STDIN_FILENO, F_GETFL)) != -1)
 | 
				
			||||||
 | 
							fcntl(STDIN_FILENO, F_SETFL, mode & ~O_NONBLOCK);
 | 
				
			||||||
 | 
						if ((mode = fcntl(STDOUT_FILENO, F_GETFL)) != -1)
 | 
				
			||||||
 | 
							fcntl(STDOUT_FILENO, F_SETFL, mode & ~O_NONBLOCK);
 | 
				
			||||||
 | 
						if ((mode = fcntl(STDERR_FILENO, F_GETFL)) != -1)
 | 
				
			||||||
 | 
							fcntl(STDERR_FILENO, F_SETFL, mode & ~O_NONBLOCK);
 | 
				
			||||||
	closefrom(STDERR_FILENO + 1);
 | 
						closefrom(STDERR_FILENO + 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	execl(shell, argv0, "-c", shellcmd, (char *) NULL);
 | 
						execl(shell, argv0, "-c", shellcmd, (char *) NULL);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user