aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2008-02-09 19:01:49 +0000
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2008-02-09 19:01:49 +0000
commit64d0b4cb703ce7a55b6d72d89bd8b355a5a93a5d (patch)
tree5d17e789bb81a015063ab6d5a136aab2daaaa732 /termkey.c
parent1f6ae5e40d2ded8d0feb91b786393f4e26dbca1f (diff)
downloadtermo-64d0b4cb703ce7a55b6d72d89bd8b355a5a93a5d.tar.gz
termo-64d0b4cb703ce7a55b6d72d89bd8b355a5a93a5d.tar.xz
termo-64d0b4cb703ce7a55b6d72d89bd8b355a5a93a5d.zip
Cope correctly with EOF
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/termkey.c b/termkey.c
index 74d6c49..7512d6b 100644
--- a/termkey.c
+++ b/termkey.c
@@ -1,5 +1,6 @@
#include "termkey.h"
+#include <errno.h>
#include <unistd.h>
#include <string.h>
@@ -370,7 +371,9 @@ void termkey_advisereadable(termkey_t *tk)
unsigned char buffer[64]; // Smaller than the default size
size_t len = read(tk->fd, buffer, sizeof buffer);
- if(len == -1)
+ if(len == -1 && errno == EAGAIN)
+ return;
+ else if(len < 1)
tk->is_closed = 1;
else
termkey_pushinput(tk, buffer, len);