Skip to contentSkip to conversation

cluster/group/tool main.c

Cluster-devel [email protected] 1 participant 1 message Nov 20, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL50
Changes by: rpeterso at sourceware.org 2006-11-20 22:36:55

Modified files:
group/tool : main.c

Log message:
Resolves: bz214524: group_tool dump can give short output.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.21.4.1&r2=1.21.4.2

group/tool/main.c +22 -10
@@ -343,11 +343,17 @@
 		return -1;
 	}
 
-	rv = read(fd, inbuf, sizeof(inbuf));
-	if (rv <= 0)
-		printf("dump read returned %d errno %d\n", rv, errno);
-	else
-		write(STDOUT_FILENO, inbuf, rv);
+	while (1) {
+		rv = read(fd, inbuf, sizeof(inbuf));
+		fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+		if (rv <= 0) {
+			if (errno != EAGAIN)
+				printf("dump read returned %d errno %d\n", rv, errno);
+			break;
+		}
+		else
+			write(STDOUT_FILENO, inbuf, rv);
+	}
 
 	close(fd);
 	return 0;
@@ -370,11 +376,17 @@
 		return -1;
 	}
 
-	rv = read(fd, inbuf, sizeof(inbuf));
-	if (rv <= 0)
-		printf("dump read returned %d errno %d\n", rv, errno);
-	else
-		write(STDOUT_FILENO, inbuf, rv);
+	while (1) {
+		rv = read(fd, inbuf, sizeof(inbuf));
+		fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+		if (rv <= 0) {
+			if (errno != EAGAIN)
+				printf("dump read returned %d errno %d\n", rv, errno);
+			break;
+		}
+		else
+			write(STDOUT_FILENO, inbuf, rv);
+	}
 
 	close(fd);
 	return 0;