Do not close panes until process has exited and any outstanding data

has been written to the pipe-pane event if there is one. GitHub issue 991.
This commit is contained in:
nicm
2017-07-03 08:16:03 +00:00
parent 42285ac989
commit 28687f2d55
4 changed files with 51 additions and 5 deletions

View File

@ -388,6 +388,19 @@ window_destroy(struct window *w)
free(w);
}
int
window_pane_destroy_ready(struct window_pane *wp)
{
if (wp->pipe_fd != -1 && EVBUFFER_LENGTH(wp->pipe_event->output) != 0)
return (0);
if (~wp->flags & PANE_EXITED)
return (0);
if (~wp->flags & PANE_ERROR)
return (0);
return (1);
}
void
window_add_ref(struct window *w, const char *from)
{
@ -1000,7 +1013,11 @@ window_pane_error_callback(__unused struct bufferevent *bufev,
{
struct window_pane *wp = data;
server_destroy_pane(wp, 1);
log_debug("%%%u error", wp->id);
wp->flags |= PANE_ERROR;
if (window_pane_destroy_ready(wp))
server_destroy_pane(wp, 1);
}
void