aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'window.c')
-rw-r--r--window.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/window.c b/window.c
index f689f01d..60a21a58 100644
--- a/window.c
+++ b/window.c
@@ -64,6 +64,7 @@ static u_int next_active_point;
struct window_pane_input_data {
struct cmdq_item *item;
u_int wp;
+ struct client_file *file;
};
static struct window_pane *window_pane_create(struct window *, u_int, u_int,
@@ -1043,6 +1044,8 @@ window_pane_set_event(struct window_pane *wp)
wp->event = bufferevent_new(wp->fd, window_pane_read_callback,
NULL, window_pane_error_callback, wp);
+ if (wp->event == NULL)
+ fatalx("out of memory");
wp->ictx = input_init(wp, wp->event, &wp->palette);
bufferevent_enable(wp->event, EV_READ|EV_WRITE);
@@ -1541,18 +1544,18 @@ window_pane_input_callback(struct client *c, __unused const char *path,
size_t len = EVBUFFER_LENGTH(buffer);
wp = window_pane_find_by_id(cdata->wp);
- if (wp == NULL || closed || error != 0 || (c->flags & CLIENT_DEAD)) {
- if (wp == NULL)
+ if (cdata->file != NULL && (wp == NULL || c->flags & CLIENT_DEAD)) {
+ if (wp == NULL) {
+ c->retval = 1;
c->flags |= CLIENT_EXIT;
-
- evbuffer_drain(buffer, len);
+ }
+ file_cancel(cdata->file);
+ } else if (cdata->file == NULL || closed || error != 0) {
cmdq_continue(cdata->item);
-
server_client_unref(c);
free(cdata);
- return;
- }
- input_parse_buffer(wp, buf, len);
+ } else
+ input_parse_buffer(wp, buf, len);
evbuffer_drain(buffer, len);
}
@@ -1575,9 +1578,8 @@ window_pane_start_input(struct window_pane *wp, struct cmdq_item *item,
cdata = xmalloc(sizeof *cdata);
cdata->item = item;
cdata->wp = wp->id;
-
+ cdata->file = file_read(c, "-", window_pane_input_callback, cdata);
c->references++;
- file_read(c, "-", window_pane_input_callback, cdata);
return (0);
}