[icinga-checkins] icinga.org: icinga2/master: Process: repeat read() until we get EAGAIN.

git at icinga.org git at icinga.org
Wed Feb 13 07:39:41 CET 2013


Module: icinga2
Branch: master
Commit: b0d8c40d20d4d7b9c82ed81c6198d86808e2b777
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=b0d8c40d20d4d7b9c82ed81c6198d86808e2b777

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Feb 13 07:39:26 2013 +0100

Process: repeat read() until we get EAGAIN.

---

 lib/base/process.cpp |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lib/base/process.cpp b/lib/base/process.cpp
index 3d7d38f..4e60961 100644
--- a/lib/base/process.cpp
+++ b/lib/base/process.cpp
@@ -380,19 +380,27 @@ bool Process::RunTask(void)
 	int rc;
 
 #ifndef _MSC_VER
-	rc = read(m_FD, buffer, sizeof(buffer));
+	do {
+		rc = read(m_FD, buffer, sizeof(buffer));
 #else /* _MSC_VER */
-	if (!feof(m_FP))
-		rc =  fread(buffer, 1, sizeof(buffer), m_FP);
-	else
-		rc = 0;
+		if (!feof(m_FP))
+			rc =  fread(buffer, 1, sizeof(buffer), m_FP);
+		else
+			rc = 0;
 #endif /* _MSC_VER */
 
-	if (rc > 0) {
-		m_OutputStream.write(buffer, rc);
+		if (rc > 0) {
+			m_OutputStream.write(buffer, rc);
+#ifdef _MSC_VER
+			return true;
+#endif /* _MSC_VER */
+		}
+#ifndef _MSC_VER
+	} while (rc > 0);
 
+	if (rc < 0 && errno == EAGAIN)
 		return true;
-	}
+#endif /* _MSC_VER */
 
 	String output = m_OutputStream.str();
 





More information about the icinga-checkins mailing list