aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-09-03 08:48:57 +0000
committerThomas Adam <thomas@xteddy.org>2012-09-04 22:35:52 +0100
commitf536dc47c46ded3eb06491e637f9a67e8f3affa1 (patch)
tree85d9ec861710361d936403c82119eb188c1a7b6d
parentd6066552ee606875e95799288819ec9f63cf09c5 (diff)
downloadrtmux-f536dc47c46ded3eb06491e637f9a67e8f3affa1.tar.gz
rtmux-f536dc47c46ded3eb06491e637f9a67e8f3affa1.tar.bz2
rtmux-f536dc47c46ded3eb06491e637f9a67e8f3affa1.zip
If stdin in the client is enable immediately, tmux will eat anything
sent to stdin before it is needed, which can be inconvenient (eg pasting commands). Instead, start with stdin disabled and reuse MSG_STDIN from server->client to mean that stdin should be enabled. Based on a diff from Chris Johnsen.
-rw-r--r--client.c7
-rw-r--r--server-fn.c3
2 files changed, 9 insertions, 1 deletions
diff --git a/client.c b/client.c
index 9ba086de..ae4f5066 100644
--- a/client.c
+++ b/client.c
@@ -285,7 +285,6 @@ client_main(int argc, char **argv, int flags)
/* Set the event and dispatch. */
client_update_event();
- event_add (&client_stdin, NULL);
event_dispatch();
/* Print the exit message, if any, and exit. */
@@ -520,6 +519,12 @@ client_dispatch_wait(void *data)
event_del(&client_stdin);
client_attached = 1;
break;
+ case MSG_STDIN:
+ if (datalen != 0)
+ fatalx("bad MSG_STDIN size");
+
+ event_add(&client_stdin, NULL);
+ break;
case MSG_STDOUT:
if (datalen != sizeof stdoutdata)
fatalx("bad MSG_STDOUT");
diff --git a/server-fn.c b/server-fn.c
index aea0fafe..b21d94a1 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -581,5 +581,8 @@ server_set_stdin_callback(struct client *c, void (*cb)(struct client *, int,
if (c->stdin_closed)
c->stdin_callback (c, 1, c->stdin_callback_data);
+
+ server_write_client(c, MSG_STDIN, NULL, 0);
+
return (0);
}