mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Call bufferevent_free before closing file descriptor associated with it
or bugs in $EventMechanism on $OtherOS makes libevent get it's knickers in a twist. From Dylan Alex Simon.
This commit is contained in:
		
							
								
								
									
										4
									
								
								job.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								job.c
									
									
									
									
									
								
							@@ -124,10 +124,10 @@ job_free(struct job *job)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (job->pid != -1)
 | 
						if (job->pid != -1)
 | 
				
			||||||
		kill(job->pid, SIGTERM);
 | 
							kill(job->pid, SIGTERM);
 | 
				
			||||||
	if (job->fd != -1)
 | 
					 | 
				
			||||||
		close(job->fd);
 | 
					 | 
				
			||||||
	if (job->event != NULL)
 | 
						if (job->event != NULL)
 | 
				
			||||||
		bufferevent_free(job->event);
 | 
							bufferevent_free(job->event);
 | 
				
			||||||
 | 
						if (job->fd != -1)
 | 
				
			||||||
 | 
							close(job->fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xfree(job);
 | 
						xfree(job);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -124,24 +124,24 @@ server_client_lost(struct client *c)
 | 
				
			|||||||
	if (c->flags & CLIENT_TERMINAL)
 | 
						if (c->flags & CLIENT_TERMINAL)
 | 
				
			||||||
		tty_free(&c->tty);
 | 
							tty_free(&c->tty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (c->stdin_event != NULL)
 | 
				
			||||||
 | 
							bufferevent_free(c->stdin_event);
 | 
				
			||||||
	if (c->stdin_fd != -1) {
 | 
						if (c->stdin_fd != -1) {
 | 
				
			||||||
		setblocking(c->stdin_fd, 1);
 | 
							setblocking(c->stdin_fd, 1);
 | 
				
			||||||
		close(c->stdin_fd);
 | 
							close(c->stdin_fd);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (c->stdin_event != NULL)
 | 
						if (c->stdout_event != NULL)
 | 
				
			||||||
		bufferevent_free(c->stdin_event);
 | 
							bufferevent_free(c->stdout_event);
 | 
				
			||||||
	if (c->stdout_fd != -1) {
 | 
						if (c->stdout_fd != -1) {
 | 
				
			||||||
		setblocking(c->stdout_fd, 1);
 | 
							setblocking(c->stdout_fd, 1);
 | 
				
			||||||
		close(c->stdout_fd);
 | 
							close(c->stdout_fd);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (c->stdout_event != NULL)
 | 
						if (c->stderr_event != NULL)
 | 
				
			||||||
		bufferevent_free(c->stdout_event);
 | 
							bufferevent_free(c->stderr_event);
 | 
				
			||||||
	if (c->stderr_fd != -1) {
 | 
						if (c->stderr_fd != -1) {
 | 
				
			||||||
		setblocking(c->stderr_fd, 1);
 | 
							setblocking(c->stderr_fd, 1);
 | 
				
			||||||
		close(c->stderr_fd);
 | 
							close(c->stderr_fd);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (c->stderr_event != NULL)
 | 
					 | 
				
			||||||
		bufferevent_free(c->stderr_event);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	status_free_jobs(&c->status_new);
 | 
						status_free_jobs(&c->status_new);
 | 
				
			||||||
	status_free_jobs(&c->status_old);
 | 
						status_free_jobs(&c->status_old);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -337,8 +337,8 @@ server_destroy_pane(struct window_pane *wp)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	old_fd = wp->fd;
 | 
						old_fd = wp->fd;
 | 
				
			||||||
	if (wp->fd != -1) {
 | 
						if (wp->fd != -1) {
 | 
				
			||||||
		close(wp->fd);
 | 
					 | 
				
			||||||
		bufferevent_free(wp->event);
 | 
							bufferevent_free(wp->event);
 | 
				
			||||||
 | 
							close(wp->fd);
 | 
				
			||||||
		wp->fd = -1;
 | 
							wp->fd = -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								window.c
									
									
									
									
									
								
							@@ -611,8 +611,8 @@ window_pane_destroy(struct window_pane *wp)
 | 
				
			|||||||
	window_pane_reset_mode(wp);
 | 
						window_pane_reset_mode(wp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (wp->fd != -1) {
 | 
						if (wp->fd != -1) {
 | 
				
			||||||
		close(wp->fd);
 | 
					 | 
				
			||||||
		bufferevent_free(wp->event);
 | 
							bufferevent_free(wp->event);
 | 
				
			||||||
 | 
							close(wp->fd);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	input_free(wp);
 | 
						input_free(wp);
 | 
				
			||||||
@@ -622,8 +622,8 @@ window_pane_destroy(struct window_pane *wp)
 | 
				
			|||||||
		grid_destroy(wp->saved_grid);
 | 
							grid_destroy(wp->saved_grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (wp->pipe_fd != -1) {
 | 
						if (wp->pipe_fd != -1) {
 | 
				
			||||||
		close(wp->pipe_fd);
 | 
					 | 
				
			||||||
		bufferevent_free(wp->pipe_event);
 | 
							bufferevent_free(wp->pipe_event);
 | 
				
			||||||
 | 
							close(wp->pipe_fd);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	RB_REMOVE(window_pane_tree, &all_window_panes, wp);
 | 
						RB_REMOVE(window_pane_tree, &all_window_panes, wp);
 | 
				
			||||||
@@ -647,8 +647,8 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
 | 
				
			|||||||
	struct termios	 tio2;
 | 
						struct termios	 tio2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (wp->fd != -1) {
 | 
						if (wp->fd != -1) {
 | 
				
			||||||
		close(wp->fd);
 | 
					 | 
				
			||||||
		bufferevent_free(wp->event);
 | 
							bufferevent_free(wp->event);
 | 
				
			||||||
 | 
							close(wp->fd);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (cmd != NULL) {
 | 
						if (cmd != NULL) {
 | 
				
			||||||
		if (wp->cmd != NULL)
 | 
							if (wp->cmd != NULL)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user