From 389e5c99ec01903fa32fb7d0a178dd416688475e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 21 Oct 2017 18:44:03 +0200 Subject: Set errno to ECONNRESET if recv returns 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libsbus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libsbus.c b/libsbus.c index 4a913ec..5b238c8 100644 --- a/libsbus.c +++ b/libsbus.c @@ -66,8 +66,11 @@ libsbus_receive(int fd, int flags, char *buf, union libsbus_packet *packet) char *p; r = recv(fd, buf, LIBSBUS_BUFFER_SIZE, flags); - if (r < 0) + if (r <= 0) { + if (!r) + errno = ECONNRESET; return -1; + } if (r >= 4 && !strncmp(buf, "MSG ", 4)) { p = memchr(buf, '\0', r); -- cgit v1.2.3-70-g09d2