summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-04-20 00:49:35 -0400
committerJune McEnroe <june@causal.agency>2018-04-20 00:49:35 -0400
commit65c418bda9a33fe5b1f8576fb46d22944798f044 (patch)
tree30f889cd1f4d24833e1e11f435671f30ea510a9a
parentUncommitted changes from months ago :( (diff)
downloadstream-65c418bda9a33fe5b1f8576fb46d22944798f044.tar.gz
stream-65c418bda9a33fe5b1f8576fb46d22944798f044.zip
Clean up ptee
Diffstat (limited to '')
-rw-r--r--ptee.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/ptee.c b/ptee.c
index 785b25a..e04fd2a 100644
--- a/ptee.c
+++ b/ptee.c
@@ -77,13 +77,12 @@ int main(int argc, char *argv[]) {
     if (pid < 0) err(EX_OSERR, "forkpty");
 
     if (!pid) {
-        execvp(*argv, argv);
-        err(EX_NOINPUT, "%s", *argv);
+        execvp(argv[0], argv);
+        err(EX_NOINPUT, "%s", argv[0]);
     }
 
     ssize_t size = write(fd.remote, &window, sizeof(window));
     if (size < 0) err(EX_IOERR, "write(%d)", fd.remote);
-    if ((size_t)size < sizeof(window)) errx(EX_IOERR, "short write(%d)", fd.remote);
 
     char buf[4096];
     ssize_t totalSize = 0;
@@ -92,28 +91,27 @@ int main(int argc, char *argv[]) {
         { .fd = fd.pty, .events = POLLIN },
     };
     while (0 < poll(fds, 2, -1)) {
-        if (fds[0].revents & POLLIN) {
-            ssize_t readSize = read(fd.input, buf, sizeof(buf));
-            if (readSize < 0) err(EX_IOERR, "read(%d)", fd.input);
+        if (fds[0].revents) {
+            ssize_t size = read(fd.input, buf, sizeof(buf));
+            if (size < 0) err(EX_IOERR, "read(%d)", fd.input);
 
-            ssize_t writeSize = write(fd.pty, buf, readSize);
-            if (writeSize < 0) err(EX_IOERR, "write(%d)", fd.pty);
-            if (writeSize < readSize) errx(EX_IOERR, "short write(%d)", fd.pty);
+            size = write(fd.pty, buf, size);
+            if (size < 0) err(EX_IOERR, "write(%d)", fd.pty);
         }
 
-        if (fds[1].revents & POLLIN) {
+        if (fds[1].revents) {
             ssize_t readSize = read(fd.pty, buf, sizeof(buf));
             if (readSize < 0) err(EX_IOERR, "read(%d)", fd.pty);
 
             ssize_t writeSize = write(fd.local, buf, readSize);
             if (writeSize < 0) err(EX_IOERR, "write(%d)", fd.local);
-            if (writeSize < readSize) err(EX_IOERR, "short write(%d)", fd.local);
 
             writeSize = write(fd.remote, buf, readSize);
             if (writeSize < 0) err(EX_IOERR, "write(%d)", fd.remote);
-            if (writeSize < readSize) err(EX_IOERR, "short write(%d)", fd.remote);
 
             if ((totalSize += readSize) >= 1024 * 1024) {
+                totalSize = 0;
+
                 struct winsize redraw = window;
                 redraw.ws_row = 1;
                 redraw.ws_col = 1;
@@ -123,8 +121,6 @@ int main(int argc, char *argv[]) {
 
                 error = ioctl(fd.pty, TIOCSWINSZ, &window);
                 if (error) err(EX_IOERR, "TIOCSWINSZ");
-
-                totalSize = 0;
             }
         }
 
ss='logsubject'>Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe In other words, warn when a function is missing static. I don't see why this isn't in -Wextra. 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe I know, it feels wrong. 2022-02-18Implement new line editing "library"June McEnroe Losing tab complete and text macros, for now. This new implementation works on an instance of a struct and does not interact with the rest of catgirl, making it possible to copy into another project. Unlike existing line editing libraries, this one is entirely abstract and can be rendered externally. My goal with this library is to be able to implement vi mode. Since it operates on struct instances rather than globals, it might also be possible to give catgirl separate line editing buffers for each window, which would be a nice UX improvement. 2022-02-18Simplify cursor positioning in inputJune McEnroe Do some extra work by adding the portion before the cursor to the input window twice, but simplify the interaction with the split point. This fixes the awkward behaviour when moving the cursor across colour codes where the code would be partially interpreted up to the cursor. 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe