commit 5497edaec0dbb2b49ba643e834c0de336b56a603
Author:     Jan Klemkow <[email protected]>
AuthorDate: Thu Apr 16 20:59:41 2020 +0200
Commit:     Jan Klemkow <[email protected]>
CommitDate: Thu Apr 16 20:59:41 2020 +0200

    ptty: better error handling

diff --git a/ptty.c b/ptty.c
index 486008d..95adc3c 100644
--- a/ptty.c
+++ b/ptty.c
@@ -111,9 +111,8 @@ main(int argc, char *argv[])
                        if ((n = read(STDIN_FILENO, buf, sizeof buf)) == -1)
                                die("read:");
                        if (n == 0) {
-                               close(mfd);
-                               //pfds = 1;
                                pfd[0].fd = -1;
+                               close(mfd);
                                break;
                        }
                        if (write(mfd, buf, n) == -1)
@@ -129,9 +128,9 @@ main(int argc, char *argv[])
                }
 
                if (pfd[0].revents & POLLHUP) {
-                       //pfds = 1;
                        pfd[0].fd = -1;
                        close(mfd);
+                       break;
                }
                if (pfd[1].revents & POLLHUP)
                        break;

Reply via email to