From c71e69ea5cd2916ece3a15718c1c774df8b2de91 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Mon, 16 Jul 2018 16:05:24 -0700 Subject: [PATCH] microcode/uxio.c (OS_channel_read): Return 0 for EIO from pty master --- src/microcode/uxio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/microcode/uxio.c b/src/microcode/uxio.c index a18ecdfc2..72a3a02f7 100644 --- a/src/microcode/uxio.c +++ b/src/microcode/uxio.c @@ -268,6 +268,16 @@ OS_channel_read (Tchannel channel, void * buffer, size_t nbytes) if (errno == ERRNO_NONBLOCK) return (-1); #endif + /* From Emacs v25.2 src/process.c: On some OSs with ptys, when + the process on one end of a pty exits, the other end gets + an error reading with errno = EIO instead of getting an EOF + (0 bytes read)... + + Thus, if a pty master and errno=EIO, return 0 bytes read. */ + if (CHANNEL_TYPE (channel) == channel_type_unix_pty_master + && errno == EIO) + return (0); + #endif /* not _ULTRIX */ UX_prim_check_errno (syscall_read); continue; -- 2.25.1