aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2016-12-05 23:39:29 +0100
committerBoris Faure <billiob@gmail.com>2016-12-05 23:39:29 +0100
commit5770c51d861cb7ad4793380b82d7e94f6a5c55a9 (patch)
tree3ba21bb0f60e03ff96b8cddcac49c9d4bab548b2
parenttermpty: ensure we're not reading from invalid fd (diff)
downloadterminology-5770c51d861cb7ad4793380b82d7e94f6a5c55a9.tar.gz
termpty: handle read() from tty pair when the other end has died, on some BSD
In such a case, read() returns 0 and sets errno to ECHILD…
-rw-r--r--src/bin/termpty.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 476c1d0..dcdfdfc 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -184,8 +184,10 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
rbuf++;
len--;
}
+ errno = 0;
len = read(ty->fd, rbuf, len);
- if (len < 0 && errno != EAGAIN)
+ if ((len < 0 && errno != EAGAIN) ||
+ (len == 0 && errno != 0))
{
/* Do not print error if the child has exited */
if (ty->pid != -1)