summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-capture-pane.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-06-01 09:43:00 +0000
committernicm <nicm@openbsd.org>2020-06-01 09:43:00 +0000
commita34cf9c854af10b16e42da7f8b8e02d14cf4d44e (patch)
treefdfafcc3f79b8a18ea3700b43f7f2428263e0174 /usr.bin/tmux/cmd-capture-pane.c
parentRevert "Ignore new Rxblock ack agreements until the WPA handshake is done." (diff)
downloadwireguard-openbsd-a34cf9c854af10b16e42da7f8b8e02d14cf4d44e.tar.xz
wireguard-openbsd-a34cf9c854af10b16e42da7f8b8e02d14cf4d44e.zip
Instead of sending all data to control mode clients as fast as possible,
add a limit of how much data will be sent to the client and try to use it for panes with some degree of fairness. GitHub issue 2217, with George Nachman.
Diffstat (limited to 'usr.bin/tmux/cmd-capture-pane.c')
-rw-r--r--usr.bin/tmux/cmd-capture-pane.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd-capture-pane.c b/usr.bin/tmux/cmd-capture-pane.c
index a250b5b980f..dd7c1c1d94c 100644
--- a/usr.bin/tmux/cmd-capture-pane.c
+++ b/usr.bin/tmux/cmd-capture-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-capture-pane.c,v 1.53 2020/04/13 10:59:58 nicm Exp $ */
+/* $OpenBSD: cmd-capture-pane.c,v 1.54 2020/06/01 09:43:00 nicm Exp $ */
/*
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
@@ -214,15 +214,20 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
if (args_has(args, 'p')) {
- if (!file_can_print(c)) {
- cmdq_error(item, "can't write output to client");
+ if (len > 0 && buf[len - 1] == '\n')
+ len--;
+ if (c->flags & CLIENT_CONTROL)
+ control_write(c, "%.*s", (int)len, buf);
+ else {
+ if (!file_can_print(c)) {
+ cmdq_error(item, "can't write to client");
+ free(buf);
+ return (CMD_RETURN_ERROR);
+ }
+ file_print_buffer(c, buf, len);
+ file_print(c, "\n");
free(buf);
- return (CMD_RETURN_ERROR);
}
- file_print_buffer(c, buf, len);
- if (args_has(args, 'P') && len > 0)
- file_print(c, "\n");
- free(buf);
} else {
bufname = NULL;
if (args_has(args, 'b'))