abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit a6418af4ddb81073538a707679f73120e739e006
parent 586d751d7e8d52a14b165b08aaef602bccf998f5
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 20 Jan 2016 12:36:58 +0100

Properly handle EOF when reading from underlying application

Diffstat:
server.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/server.c b/server.c @@ -99,9 +99,11 @@ error: static bool server_read_pty(Packet *pkt) { pkt->type = MSG_CONTENT; ssize_t len = read(server.pty, pkt->u.msg, sizeof(pkt->u.msg)); - if (len != -1) + if (len > 0) pkt->len = len; - else if (errno != EAGAIN && errno != EINTR) + else if (len == 0) + server.running = false; + else if (len == -1 && errno != EAGAIN && errno != EINTR && errno != EWOULDBLOCK) server.running = false; print_packet("server-read-pty:", pkt); return len > 0;