summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/subprocess-win32.cc5
-rw-r--r--src/subprocess.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc
index e757f7e..c0185e4 100644
--- a/src/subprocess-win32.cc
+++ b/src/subprocess-win32.cc
@@ -28,7 +28,7 @@ void Win32Fatal(const char* function) {
} // anonymous namespace
-Subprocess::Subprocess() : child_(NULL) , overlapped_() {
+Subprocess::Subprocess() : child_(NULL) , overlapped_(), is_reading_(false) {
}
Subprocess::~Subprocess() {
@@ -130,10 +130,11 @@ void Subprocess::OnPipeReady() {
Win32Fatal("GetOverlappedResult");
}
- if (bytes)
+ if (is_reading_ && bytes)
buf_.append(overlapped_buf_, bytes);
memset(&overlapped_, 0, sizeof(overlapped_));
+ is_reading_ = true;
if (!::ReadFile(pipe_, overlapped_buf_, sizeof(overlapped_buf_),
&bytes, &overlapped_)) {
if (GetLastError() == ERROR_BROKEN_PIPE) {
diff --git a/src/subprocess.h b/src/subprocess.h
index 9828bf4..f355944 100644
--- a/src/subprocess.h
+++ b/src/subprocess.h
@@ -52,6 +52,7 @@ struct Subprocess {
HANDLE pipe_;
OVERLAPPED overlapped_;
char overlapped_buf_[4 << 10];
+ bool is_reading_;
#else
int fd_;
pid_t pid_;