[1/3] progress_ipc: Add non-blocking receive support

Message ID 1515408521-31480-1-git-send-email-stefan@herbrechtsmeier.net
State Changes Requested
Headers show
Series
  • [1/3] progress_ipc: Add non-blocking receive support
Related show

Commit Message

Stefan Herbrechtsmeier Jan. 8, 2018, 10:48 a.m.
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---
 ipc/progress_ipc.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/ipc/progress_ipc.c b/ipc/progress_ipc.c
index 881d2c7..ca60f67 100644
--- a/ipc/progress_ipc.c
+++ b/ipc/progress_ipc.c
@@ -19,6 +19,7 @@ 
 
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -61,11 +62,16 @@  int progress_ipc_connect(bool reconnect)
 
 int progress_ipc_receive(int *connfd, struct progress_msg *msg) {
 	int ret = read(*connfd, msg, sizeof(*msg));
+
+	if (ret == -1 && errno == EAGAIN)
+		return 0;
+
 	if (ret != sizeof(*msg)) {
 		fprintf(stdout, "Connection closing..\n");
 		close(*connfd);
 		*connfd = -1;
 		return -1;
 	}
+
 	return ret;
 }