Okay, I removed the delay in the attached version of the patch which I
will send upstream.  I post it here just for sake of completeness.

Regards,
Dennis.
--- speechd-up-0.5~20110719/speechd-up.c	2020-09-02 21:05:47.357273940 +0200
+++ speechd-up-0.5~20110719/speechd-up.c	2020-09-02 21:07:45.929271575 +0200
@@ -631,6 +631,7 @@
 int main(int argc, char *argv[])
 {
 	size_t chars_read;
+	ssize_t chars_read_signed;
 	char buf[BUF_SIZE + 1];
 	int ret;

@@ -748,11 +749,19 @@
 			close(fd);
 			return -1;
 		}
-		chars_read = read(fd, buf, BUF_SIZE);
-		if (chars_read < 0) {
-			FATAL(5, "read() failed");
-			close(fd);
-			return -1;
+		chars_read_signed = read(fd, buf, BUF_SIZE);
+		if (chars_read_signed < 0) {
+			if (errno == EAGAIN) {
+				LOG(5, "read() failed with EAGAIN, retrying");
+				continue;
+			} else {
+				FATAL(5, "read() failed with %d,%s",
+				      errno, strerror(errno));
+				close(fd);
+				return -1;
+			}
+		} else {
+			chars_read = chars_read_signed;
 		}
 		buf[chars_read] = 0;
 		LOG(5, "Main loop characters read = %d : (%s)", chars_read,

Reply via email to