summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2018-02-22 10:11:11 -0500
committerJune McEnroe <programble@gmail.com>2018-02-22 10:11:11 -0500
commitc744f494a07ec392cb520ee823c6eb6200e8d44e (patch)
treeb50d50fd74f22f29750a06e43ac7f3e4066a51e8
parentHandle truncation in view (diff)
downloadstream-c744f494a07ec392cb520ee823c6eb6200e8d44e.tar.gz
stream-c744f494a07ec392cb520ee823c6eb6200e8d44e.zip
Send ^L to PTY every 1 MiB in broadcast
Diffstat (limited to '')
-rw-r--r--broadcast.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/broadcast.c b/broadcast.c
index afea3e4..c31112e 100644
--- a/broadcast.c
+++ b/broadcast.c
@@ -85,6 +85,7 @@ int main(int argc, char *argv[]) {
     }
 
     char buf[4096];
+    ssize_t totalSize = 0;
     struct pollfd fds[2] = {
         { .fd = input, .events = POLLIN },
         { .fd = pty, .events = POLLIN },
@@ -110,6 +111,14 @@ int main(int argc, char *argv[]) {
             writeSize = write(remote, buf, readSize);
             if (writeSize < 0) err(EX_IOERR, "write(%d)", remote);
             if (writeSize < readSize) errx(EX_IOERR, "short write(%d)", remote);
+
+            totalSize += readSize;
+            if (totalSize > 1024 * 1024) {
+                buf[0] = CTRL('L');
+                writeSize = write(pty, buf, 1);
+                if (writeSize < 0) err(EX_IOERR, "write(%d)", pty);
+                totalSize = 0;
+            }
         }
 
         int status;