Ninja
SubprocessSet Struct Reference

SubprocessSet runs a ppoll/pselect() loop around a set of Subprocesses. More...

#include <subprocess.h>

Public Member Functions

SubprocessAdd (const std::string &command, bool use_console=false)
 
void CheckConsoleProcessTerminated ()
 
void Clear ()
 
bool DoWork ()
 
SubprocessNextFinished ()
 
 SubprocessSet ()
 
 ~SubprocessSet ()
 

Static Public Member Functions

static void HandlePendingInterruption ()
 
static bool IsInterrupted ()
 Whether ninja should quit. Set on SIGINT, SIGTERM or SIGHUP reception.
 
static void SetInterruptedFlag (int signum)
 
static void SigChldHandler (int signo, siginfo_t *info, void *context)
 

Public Attributes

std::queue< Subprocess * > finished_
 
struct sigaction old_chld_act_
 
struct sigaction old_hup_act_
 
struct sigaction old_int_act_
 
sigset_t old_mask_
 
struct sigaction old_term_act_
 
std::vector< Subprocess * > running_
 

Static Public Attributes

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().
 

Detailed Description

SubprocessSet runs a ppoll/pselect() loop around a set of Subprocesses.

DoWork() waits for any state change in subprocesses; finished_ is a queue of subprocesses as they finish.

Definition at line 101 of file subprocess.h.

Constructor & Destructor Documentation

◆ SubprocessSet()

SubprocessSet::SubprocessSet ( )

◆ ~SubprocessSet()

SubprocessSet::~SubprocessSet ( )

Member Function Documentation

◆ Add()

Subprocess * SubprocessSet::Add ( const std::string & command,
bool use_console = false )

Definition at line 311 of file subprocess-posix.cc.

References running_, and Subprocess::Start().

◆ CheckConsoleProcessTerminated()

void SubprocessSet::CheckConsoleProcessTerminated ( )

Definition at line 283 of file subprocess-posix.cc.

References finished_, running_, and s_sigchld_received.

Referenced by DoWork().

◆ Clear()

void SubprocessSet::Clear ( )

Definition at line 451 of file subprocess-posix.cc.

References interrupted_, and running_.

Referenced by ~SubprocessSet().

◆ DoWork()

◆ HandlePendingInterruption()

void SubprocessSet::HandlePendingInterruption ( )
static

Definition at line 237 of file subprocess-posix.cc.

References interrupted_.

Referenced by DoWork().

◆ IsInterrupted()

static bool SubprocessSet::IsInterrupted ( )
inlinestatic

Whether ninja should quit. Set on SIGINT, SIGTERM or SIGHUP reception.

Definition at line 124 of file subprocess.h.

References interrupted_.

Referenced by DoWork().

◆ NextFinished()

Subprocess * SubprocessSet::NextFinished ( )

Definition at line 443 of file subprocess-posix.cc.

References finished_.

◆ SetInterruptedFlag()

void SubprocessSet::SetInterruptedFlag ( int signum)
static

Definition at line 229 of file subprocess-posix.cc.

References interrupted_.

Referenced by SubprocessSet().

◆ SigChldHandler()

void SubprocessSet::SigChldHandler ( int signo,
siginfo_t * info,
void * context )
static

Definition at line 233 of file subprocess-posix.cc.

References s_sigchld_received.

Referenced by SubprocessSet().

Member Data Documentation

◆ finished_

std::queue<Subprocess*> SubprocessSet::finished_

Definition at line 111 of file subprocess.h.

Referenced by CheckConsoleProcessTerminated(), DoWork(), and NextFinished().

◆ interrupted_

volatile sig_atomic_t SubprocessSet::interrupted_
static

Store the signal number that causes the interruption.

0 if not interruption.

Definition at line 122 of file subprocess.h.

Referenced by Clear(), DoWork(), HandlePendingInterruption(), IsInterrupted(), and SetInterruptedFlag().

◆ old_chld_act_

struct sigaction SubprocessSet::old_chld_act_

Definition at line 135 of file subprocess.h.

Referenced by SubprocessSet(), and ~SubprocessSet().

◆ old_hup_act_

struct sigaction SubprocessSet::old_hup_act_

Definition at line 134 of file subprocess.h.

Referenced by SubprocessSet(), and ~SubprocessSet().

◆ old_int_act_

struct sigaction SubprocessSet::old_int_act_

Definition at line 132 of file subprocess.h.

Referenced by SubprocessSet(), and ~SubprocessSet().

◆ old_mask_

sigset_t SubprocessSet::old_mask_

Definition at line 136 of file subprocess.h.

Referenced by DoWork(), Subprocess::Start(), SubprocessSet(), and ~SubprocessSet().

◆ old_term_act_

struct sigaction SubprocessSet::old_term_act_

Definition at line 133 of file subprocess.h.

Referenced by SubprocessSet(), and ~SubprocessSet().

◆ running_

std::vector<Subprocess*> SubprocessSet::running_

Definition at line 110 of file subprocess.h.

Referenced by Add(), CheckConsoleProcessTerminated(), Clear(), and DoWork().

◆ s_sigchld_received

volatile sig_atomic_t SubprocessSet::s_sigchld_received
static

Initialized to 0 before ppoll/pselect().

Filled to 1 by SIGCHLD handler when a child process terminates.

Definition at line 129 of file subprocess.h.

Referenced by CheckConsoleProcessTerminated(), DoWork(), and SigChldHandler().


The documentation for this struct was generated from the following files: