15 #ifndef NINJA_SUBPROCESS_H_
16 #define NINJA_SUBPROCESS_H_
30 # include <sys/param.h>
31 # if defined USE_PPOLL && __FreeBSD_version < 1002000
63 HANDLE SetupPipe(HANDLE ioport);
67 OVERLAPPED overlapped_;
68 char overlapped_buf_[4 << 10];
105 Subprocess*
Add(
const std::string& command,
bool use_console =
false);
114 static BOOL WINAPI NotifyInterrupted(DWORD dwCtrlType);
115 static HANDLE ioport_;
118 static void SigChldHandler(
int signo, siginfo_t* info,
void* context);
SubprocessSet runs a ppoll/pselect() loop around a set of Subprocesses.
void CheckConsoleProcessTerminated()
std::queue< Subprocess * > finished_
static void HandlePendingInterruption()
Subprocess * NextFinished()
static volatile sig_atomic_t interrupted_
Store the signal number that causes the interruption.
static volatile sig_atomic_t s_sigchld_received
Initialized to 0 before ppoll/pselect().
struct sigaction old_hup_act_
static void SetInterruptedFlag(int signum)
struct sigaction old_chld_act_
std::vector< Subprocess * > running_
struct sigaction old_int_act_
struct sigaction old_term_act_
static void SigChldHandler(int signo, siginfo_t *info, void *context)
static bool IsInterrupted()
Whether ninja should quit. Set on SIGINT, SIGTERM or SIGHUP reception.
Subprocess * Add(const std::string &command, bool use_console=false)
Subprocess wraps a single async subprocess.
bool Start(struct SubprocessSet *set, const std::string &command)
bool TryFinish(int waitpid_options)
Call waitpid() on the subprocess with the provided options and update the pid_ and exit_status_ field...
ExitStatus exit_status_
In POSIX platforms it is necessary to use waitpid(WNOHANG) to know whether a certain subprocess has f...
Subprocess(bool use_console)
int fd_
The file descriptor that will be used in ppoll/pselect() for this process, if any.
ExitStatus Finish()
Returns ExitSuccess on successful process exit, ExitInterrupted if the process was interrupted,...
const std::string & GetOutput() const
pid_t pid_
PID of the subprocess. Set to -1 when the subprocess is reaped.