has been written to the pipe-pane event if there is one. GitHub issue 991.
-/* $OpenBSD: cmd-pipe-pane.c,v 1.42 2017/05/01 12:20:55 nicm Exp $ */
+/* $OpenBSD: cmd-pipe-pane.c,v 1.43 2017/07/03 08:16:03 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
static enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmdq_item *);
+static void cmd_pipe_pane_write_callback(struct bufferevent *, void *);
static void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
const struct cmd_entry cmd_pipe_pane_entry = {
bufferevent_free(wp->pipe_event);
close(wp->pipe_fd);
wp->pipe_fd = -1;
+
+ if (window_pane_destroy_ready(wp)) {
+ server_destroy_pane(wp, 1);
+ return (CMD_RETURN_NORMAL);
+ }
}
/* If no pipe command, that is enough. */
wp->pipe_fd = pipe_fd[0];
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
- wp->pipe_event = bufferevent_new(wp->pipe_fd,
- NULL, NULL, cmd_pipe_pane_error_callback, wp);
+ wp->pipe_event = bufferevent_new(wp->pipe_fd, NULL,
+ cmd_pipe_pane_write_callback, cmd_pipe_pane_error_callback,
+ wp);
bufferevent_enable(wp->pipe_event, EV_WRITE);
setblocking(wp->pipe_fd, 0);
}
}
+static void
+cmd_pipe_pane_write_callback(__unused struct bufferevent *bufev, void *data)
+{
+ struct window_pane *wp = data;
+
+ log_debug("%%%u pipe empty", wp->id);
+ if (window_pane_destroy_ready(wp))
+ server_destroy_pane(wp, 1);
+}
+
static void
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev,
__unused short what, void *data)
{
struct window_pane *wp = data;
+ log_debug("%%%u pipe error", wp->id);
+
bufferevent_free(wp->pipe_event);
close(wp->pipe_fd);
wp->pipe_fd = -1;
+
+ if (window_pane_destroy_ready(wp))
+ server_destroy_pane(wp, 1);
}
-/* $OpenBSD: server.c,v 1.171 2017/06/04 08:25:57 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.172 2017/07/03 08:16:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp->pid == pid) {
wp->status = status;
- server_destroy_pane(wp, 1);
+
+ log_debug("%%%u exited", wp->id);
+ wp->flags |= PANE_EXITED;
+
+ if (window_pane_destroy_ready(wp))
+ server_destroy_pane(wp, 1);
break;
}
}
-/* $OpenBSD: tmux.h,v 1.789 2017/06/30 22:24:08 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.790 2017/07/03 08:16:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
#define PANE_FOCUSPUSH 0x20
#define PANE_INPUTOFF 0x40
#define PANE_CHANGED 0x80
+#define PANE_ERROR 0x100
+#define PANE_EXITED 0x200
int argc;
char **argv;
void window_destroy_panes(struct window *);
struct window_pane *window_pane_find_by_id_str(const char *);
struct window_pane *window_pane_find_by_id(u_int);
+int window_pane_destroy_ready(struct window_pane *);
int window_pane_spawn(struct window_pane *, int, char **,
const char *, const char *, const char *, struct environ *,
struct termios *, char **);
int window_pane_outside(struct window_pane *);
int window_pane_visible(struct window_pane *);
u_int window_pane_search(struct window_pane *, const char *);
-
const char *window_printable_flags(struct winlink *);
struct window_pane *window_pane_find_up(struct window_pane *);
struct window_pane *window_pane_find_down(struct window_pane *);
-/* $OpenBSD: window.c,v 1.199 2017/06/28 11:36:40 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.200 2017/07/03 08:16:03 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
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)
{
{
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