From: Ken Hornstein Date: Thu, 18 May 2017 01:40:57 +0000 (-0400) Subject: Apparently on Linux if a slave pty is closed, instead of the master X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/d11f8c6ba92fc28c3ea4d76676ff7d5148c36d7d Apparently on Linux if a slave pty is closed, instead of the master 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. --- diff --git a/test/runpty.c b/test/runpty.c index a2fe6f48..e5de14e0 100644 --- a/test/runpty.c +++ b/test/runpty.c @@ -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);