summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authornicm <nicm>2023-01-06 07:09:27 +0000
committernicm <nicm>2023-01-06 07:09:27 +0000
commit09afc6c8ee971918d925c441c41a9de7f598efb7 (patch)
tree790231afa3b8ae46b4b7dc13a925a23c0dc5dfdc /window.c
parenta41a92744188ec5c8a8d4ddc100ec15b52d04603 (diff)
If a pane is killed, cancel reading from the file. GitHub issue 3422.
Diffstat (limited to 'window.c')
-rw-r--r--window.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/window.c b/window.c
index 1b0066c2..4929383e 100644
--- a/window.c
+++ b/window.c
@@ -66,6 +66,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,
@@ -1533,18 +1534,16 @@ 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 (cdata->file != NULL && (wp == NULL || c->flags & CLIENT_DEAD)) {
if (wp == NULL)
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);
}
@@ -1567,9 +1566,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);
}