summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authornicm <nicm>2019-12-12 11:39:56 +0000
committernicm <nicm>2019-12-12 11:39:56 +0000
commitc284ebe0ade7cc85ad6c3fe5ce7ed5108119222d (patch)
tree52fa29b04da1e5468bdce23cce61bf0370923c2e /window.c
parent64fb7e472a9e627ee486707ab9d30b607d76478a (diff)
Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to how works for stdin, stdout, stderr. This makes special files like /dev/fd/X work (used by some shells). stdin, stdout and stderr and control mode are now just special cases of the same mechanism. This will also make it easier to use for other commands that read files such as source-file.
Diffstat (limited to 'window.c')
-rw-r--r--window.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/window.c b/window.c
index bde9693b..64c95855 100644
--- a/window.c
+++ b/window.c
@@ -1598,31 +1598,28 @@ winlink_shuffle_up(struct session *s, struct winlink *wl)
}
static void
-window_pane_input_callback(struct client *c, int closed, void *data)
+window_pane_input_callback(struct client *c, __unused const char *path,
+ int error, int closed, struct evbuffer *buffer, void *data)
{
struct window_pane_input_data *cdata = data;
struct window_pane *wp;
- struct evbuffer *evb = c->stdin_data;
- u_char *buf = EVBUFFER_DATA(evb);
- size_t len = EVBUFFER_LENGTH(evb);
+ u_char *buf = EVBUFFER_DATA(buffer);
+ size_t len = EVBUFFER_LENGTH(buffer);
wp = window_pane_find_by_id(cdata->wp);
- if (wp == NULL || closed || c->flags & CLIENT_DEAD) {
+ if (wp == NULL || closed || error != 0 || c->flags & CLIENT_DEAD) {
if (wp == NULL)
c->flags |= CLIENT_EXIT;
- evbuffer_drain(evb, len);
-
- c->stdin_callback = NULL;
- server_client_unref(c);
+ evbuffer_drain(buffer, len);
cmdq_continue(cdata->item);
- free(cdata);
+ server_client_unref(c);
+ free(cdata);
return;
}
-
input_parse_buffer(wp, buf, len);
- evbuffer_drain(evb, len);
+ evbuffer_drain(buffer, len);
}
int
@@ -1641,6 +1638,8 @@ window_pane_start_input(struct window_pane *wp, struct cmdq_item *item,
cdata->item = item;
cdata->wp = wp->id;
- return (server_set_stdin_callback(c, window_pane_input_callback, cdata,
- cause));
+ c->references++;
+ file_read(c, "-", window_pane_input_callback, cdata);
+
+ return (0);
}