summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4b220f6)
raw | patch | inline | side by side (parent: 4b220f6)
author | ishmal <ishmal@users.sourceforge.net> | |
Fri, 6 Jun 2008 18:36:58 +0000 (18:36 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Fri, 6 Jun 2008 18:36:58 +0000 (18:36 +0000) |
buildtool.cpp | patch | blob | history |
diff --git a/buildtool.cpp b/buildtool.cpp
index 1dee1044826b175af138feaf3107d1948d404849..da482971b58b63b27f4eff053ad91f24057f6061 100644 (file)
--- a/buildtool.cpp
+++ b/buildtool.cpp
#ifdef __WIN32__
#include <windows.h>
-#else
-#include <sys/wait.h>
#endif
#else /*do it unix style*/
+#include <sys/wait.h>
+
/**
* Execute a system call, using pipes to send data to the
* program's stdin, and reading stdout and stderr.
String outb;
String errb;
- while (1)
- {
- unsigned char outch;
- int rout = read(outfds[0], &outch, 1);
- if (rout>0)
- outb.push_back(outch);
- unsigned char errch;
- int rerr = read(errfds[0], &errch, 1);
- if (rerr>0)
- errb.push_back(errch);
- if (rout <=0 && rerr <=0)
+ FILE *stdOutRead = fdopen(outfds[0], "r");
+ while (!feof(stdOutRead))
+ {
+ char ch = fgetc(stdOutRead);
+ if (ch<0)
+ break;
+ outb.push_back(ch);
+ }
+ FILE *stdErrRead = fdopen(errfds[0], "r");
+ while (!feof(stdErrRead))
+ {
+ char ch = fgetc(stdErrRead);
+ if (ch<0)
break;
+ errb.push_back(ch);
}
int childReturnValue;
wait(&childReturnValue);
- close(outfds[0]);
- close(errfds[0]);
+ fclose(stdOutRead);
+ fclose(stdErrRead);
outbuf = outb;
errbuf = errb;