From: nicm Date: Mon, 3 Jul 2017 12:38:50 +0000 (+0000) Subject: Change previous to not wait for both process exit and pty close - X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9017429c5fca582268b459cc1fd5a0966278e72e;p=openbsd Change previous to not wait for both process exit and pty close - instead if there is a pipe-pane active, do not exit until all data is read (including any libevent hasn't seen yet). Fixes problem reported by Theo Buehler and still seems to solve the original issue. --- diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 345da8a6326..53366098eef 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.790 2017/07/03 08:16:03 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.791 2017/07/03 12:38:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -768,8 +768,7 @@ struct window_pane { #define PANE_FOCUSPUSH 0x20 #define PANE_INPUTOFF 0x40 #define PANE_CHANGED 0x80 -#define PANE_ERROR 0x100 -#define PANE_EXITED 0x200 +#define PANE_EXITED 0x100 int argc; char **argv; diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 2d3645aa905..f2f2d139ca3 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.200 2017/07/03 08:16:03 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.201 2017/07/03 12:38:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -391,13 +391,17 @@ window_destroy(struct window *w) int window_pane_destroy_ready(struct window_pane *wp) { - if (wp->pipe_fd != -1 && EVBUFFER_LENGTH(wp->pipe_event->output) != 0) - return (0); + int n; + + if (wp->pipe_fd != -1) { + if (EVBUFFER_LENGTH(wp->pipe_event->output) != 0) + return (0); + if (ioctl(wp->fd, FIONREAD, &n) != -1 && n > 0) + return (0); + } if (~wp->flags & PANE_EXITED) return (0); - if (~wp->flags & PANE_ERROR) - return (0); return (1); } @@ -1014,7 +1018,7 @@ window_pane_error_callback(__unused struct bufferevent *bufev, struct window_pane *wp = data; log_debug("%%%u error", wp->id); - wp->flags |= PANE_ERROR; + wp->flags |= PANE_EXITED; if (window_pane_destroy_ready(wp)) server_destroy_pane(wp, 1);