summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-09-03 08:48:58 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-09-03 08:48:58 +0000
commit8541c9752590e9b6dba2f0258d47bfc964b121bb (patch)
tree9948dd80b7a192b38f846b0b5b7e6193bd293bad /usr.bin
parent6e8857878433f6785419f808b8036f0b1941776a (diff)
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.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/client.c9
-rw-r--r--usr.bin/tmux/server-fn.c5
2 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index cbfa8d0775d..f6d430de93f 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.59 2012/08/27 21:35:11 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.60 2012/09/03 08:48:57 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -281,7 +281,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. */
@@ -516,6 +515,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/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index 6eba98075cc..67ebb9ae654 100644
--- a/usr.bin/tmux/server-fn.c
+++ b/usr.bin/tmux/server-fn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-fn.c,v 1.60 2012/07/10 11:53:01 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.61 2012/09/03 08:48:57 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
}