aboutsummaryrefslogtreecommitdiff
path: root/tmux.h
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-07-24 20:11:59 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-07-24 20:11:59 +0000
commitc87187f913f853a650a00ca0328817987298f7d0 (patch)
tree41315e86224393a16a23460034da98991dfbf656 /tmux.h
parentbf09b00fe946a06c2f1192bd213f26e5a47889a8 (diff)
downloadrtmux-c87187f913f853a650a00ca0328817987298f7d0.tar.gz
rtmux-c87187f913f853a650a00ca0328817987298f7d0.tar.bz2
rtmux-c87187f913f853a650a00ca0328817987298f7d0.zip
When changing so that the client passes its stdout and stderr as well as
stdin up to the server, I forgot one essential point - the tmux server could now be both the producer and consumer. This happens when tmux is run inside tmux, as well as when piping tmux commands together. So, using stdio(3) was a bad idea - if sufficient data was written, this could block in write(2). When that happened and the server was both producer and consumer, it deadlocks. Change to use libevent bufferevents for the client stdin, stdout and stderr instead. This is trivial enough for output but requires a callback mechanism to trigger when stdin is finished. This relies on the underlying polling mechanism for libevent to work with whatever devices to which the user could redirect stdin, stdout or stderr, hence the change to use poll(2) over kqueue(2) for tmux.
Diffstat (limited to 'tmux.h')
-rw-r--r--tmux.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/tmux.h b/tmux.h
index 8a4ec29d..e1cd0b7e 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1096,9 +1096,17 @@ struct client {
char *cwd;
struct tty tty;
- FILE *stdin_file;
- FILE *stdout_file;
- FILE *stderr_file;
+
+ int stdin_fd;
+ void *stdin_data;
+ void (*stdin_callback)(struct client *, void *);
+ struct bufferevent *stdin_event;
+
+ int stdout_fd;
+ struct bufferevent *stdout_event;
+
+ int stderr_fd;
+ struct bufferevent *stderr_event;
struct event repeat_timer;
@@ -1108,7 +1116,7 @@ struct client {
#define CLIENT_TERMINAL 0x1
#define CLIENT_PREFIX 0x2
-/* 0x4 unused */
+#define CLIENT_EXIT 0x4
#define CLIENT_REDRAW 0x8
#define CLIENT_STATUS 0x10
#define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */