diff options
author | Evan Martin <martine@danga.com> | 2011-05-06 18:46:11 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-05-06 19:21:06 (GMT) |
commit | 6cf3f79fb45e196bd47ea25f9c030c3364494ebc (patch) | |
tree | ad165d26cee376a8383b3ffa44acbb31cad4626c /src/subprocess.cc | |
parent | 661c5435e8bf108ded8ba795cc0a3aafda03b791 (diff) | |
download | Ninja-6cf3f79fb45e196bd47ea25f9c030c3364494ebc.zip Ninja-6cf3f79fb45e196bd47ea25f9c030c3364494ebc.tar.gz Ninja-6cf3f79fb45e196bd47ea25f9c030c3364494ebc.tar.bz2 |
windows: subprocess implementation for Windows
Heavily based on a patch from Sergey Nenakhov <nenakhov.sergey@gmail.com>.
Diffstat (limited to 'src/subprocess.cc')
-rw-r--r-- | src/subprocess.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/subprocess.cc b/src/subprocess.cc index 907c248..c2e306c 100644 --- a/src/subprocess.cc +++ b/src/subprocess.cc @@ -37,7 +37,7 @@ Subprocess::~Subprocess() { Finish(); } -bool Subprocess::Start(const string& command) { +bool Subprocess::Start(SubprocessSet* set, const string& command) { int output_pipe[2]; if (pipe(output_pipe) < 0) Fatal("pipe: %s", strerror(errno)); @@ -84,7 +84,7 @@ bool Subprocess::Start(const string& command) { return true; } -void Subprocess::OnFDReady() { +void Subprocess::OnPipeReady() { char buf[4 << 10]; ssize_t len = read(fd_, buf, sizeof(buf)); if (len > 0) { @@ -120,6 +120,9 @@ const string& Subprocess::GetOutput() const { return buf_; } +SubprocessSet::SubprocessSet() {} +SubprocessSet::~SubprocessSet() {} + void SubprocessSet::Add(Subprocess* subprocess) { running_.push_back(subprocess); } @@ -151,7 +154,7 @@ void SubprocessSet::DoWork() { for (size_t i = 0; i < fds.size(); ++i) { if (fds[i].revents) { Subprocess* subproc = fd_to_subprocess[fds[i].fd]; - subproc->OnFDReady(); + subproc->OnPipeReady(); if (subproc->Done()) { finished_.push(subproc); std::remove(running_.begin(), running_.end(), subproc); |