]> diplodocus.org Git - nmh/commitdiff
Apparently on Linux if a slave pty is closed, instead of the master
authorKen Hornstein <kenh@pobox.com>
Thu, 18 May 2017 01:40:57 +0000 (21:40 -0400)
committerKen Hornstein <kenh@pobox.com>
Thu, 18 May 2017 01:40:57 +0000 (21:40 -0400)
getting an EOF they get an EIO, which strikes me as unfriendly.  So
make sure we exit the main read loop without complaint on an EOF or
error.

test/runpty.c

index a2fe6f4..e5de14e 100644 (file)
@@ -136,12 +136,7 @@ main(int argc, char *argv[])
        if (cc > 0 && FD_ISSET(master, &readfds)) {
            cc = read(master, readbuf, sizeof(readbuf));
 
-           if (cc < 0) {
-               fprintf(stderr, "read() failed: %s\n", strerror(errno));
-               exit(1);
-           }
-
-           if (cc == 0)
+           if (cc <= 0)
                break;
 
            fwrite(readbuf, 1, cc, output);