diff options
Diffstat (limited to 'src/subprocess.h')
-rw-r--r-- | src/subprocess.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/subprocess.h b/src/subprocess.h index 934a220..9828bf4 100644 --- a/src/subprocess.h +++ b/src/subprocess.h @@ -20,6 +20,10 @@ #include <queue> using namespace std; +#ifdef _WIN32 +#include <windows.h> +#endif + /// Subprocess wraps a single async subprocess. It is entirely /// passive: it expects the caller to notify it when its fds are ready /// for reading, as well as call Finish() to reap the child once done() @@ -27,8 +31,8 @@ using namespace std; struct Subprocess { Subprocess(); ~Subprocess(); - bool Start(const string& command); - void OnFDReady(); + bool Start(struct SubprocessSet* set, const string& command); + void OnPipeReady(); /// Returns true on successful process exit. bool Finish(); @@ -38,8 +42,20 @@ struct Subprocess { private: string buf_; + +#ifdef _WIN32 + /// Set up pipe_ as the parent-side pipe of the subprocess; return the + /// other end of the pipe, usable in the child process. + HANDLE SetupPipe(HANDLE ioport); + + HANDLE child_; + HANDLE pipe_; + OVERLAPPED overlapped_; + char overlapped_buf_[4 << 10]; +#else int fd_; pid_t pid_; +#endif friend struct SubprocessSet; }; @@ -48,12 +64,19 @@ struct Subprocess { /// DoWork() waits for any state change in subprocesses; finished_ /// is a queue of subprocesses as they finish. struct SubprocessSet { + SubprocessSet(); + ~SubprocessSet(); + void Add(Subprocess* subprocess); void DoWork(); Subprocess* NextFinished(); vector<Subprocess*> running_; queue<Subprocess*> finished_; + +#ifdef _WIN32 + HANDLE ioport_; +#endif }; #endif // NINJA_SUBPROCESS_H_ |