From mboxrd@z Thu Jan 1 00:00:00 1970 From: rpeterso@sourceware.org Date: 9 Nov 2006 16:23:41 -0000 Subject: [Cluster-devel] cluster/group/tool main.c Message-ID: <20061109162341.20204.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Branch: RHEL5 Changes by: rpeterso at sourceware.org 2006-11-09 16:23:41 Modified files: group/tool : main.c Log message: This is the fix for Bugzilla Bug 214524: 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=RHEL5&r1=1.21.2.1&r2=1.21.2.2 --- cluster/group/tool/main.c 2006/11/09 15:51:01 1.21.2.1 +++ cluster/group/tool/main.c 2006/11/09 16:23:41 1.21.2.2 @@ -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;