diff options
author | Evan Martin <martine@danga.com> | 2011-05-03 04:42:11 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-05-03 04:42:11 (GMT) |
commit | 8e0f8d7d049fa5fd93f0951f46a4a09ac3778ed2 (patch) | |
tree | c5d6c422848c6a497d46e86de40aa12c2b0c91a6 /src/subprocess.h | |
parent | 4be3bcedcde248fdfb1e19d6883da8532ba9e430 (diff) | |
download | Ninja-8e0f8d7d049fa5fd93f0951f46a4a09ac3778ed2.zip Ninja-8e0f8d7d049fa5fd93f0951f46a4a09ac3778ed2.tar.gz Ninja-8e0f8d7d049fa5fd93f0951f46a4a09ac3778ed2.tar.bz2 |
refactor subprocess to make it easier for windows port
Rather than tracking stdout/stderr explicitly, just keep an opaque
pointer to a platform-specific 'stream' type. Also provide API
to get at the process output.
Diffstat (limited to 'src/subprocess.h')
-rw-r--r-- | src/subprocess.h | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/subprocess.h b/src/subprocess.h index a1edb0d..048bacb 100644 --- a/src/subprocess.h +++ b/src/subprocess.h @@ -28,21 +28,16 @@ struct Subprocess { Subprocess(); ~Subprocess(); bool Start(const string& command); - void OnFDReady(int fd); + void OnFDReady(); /// Returns true on successful process exit. bool Finish(); - bool done() const { - return stdout_.fd_ == -1 && stderr_.fd_ == -1; - } - - struct Stream { - Stream(); - ~Stream(); - int fd_; - string buf_; - }; - Stream stdout_, stderr_; + bool Done() const; + + const string& GetOutput() const; + + struct Stream; + Stream* stream_; pid_t pid_; }; |