Ninja
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Subprocess Struct Reference

Subprocess wraps a single async subprocess. More...

#include <subprocess.h>

Public Member Functions

bool Done () const
 
ExitStatus Finish ()
 Returns ExitSuccess on successful process exit, ExitInterrupted if the process was interrupted, ExitFailure if it otherwise failed. More...
 
const string & GetOutput () const
 
 ~Subprocess ()
 

Private Member Functions

void OnPipeReady ()
 
bool Start (struct SubprocessSet *set, const string &command)
 
 Subprocess (bool use_console)
 

Private Attributes

string buf_
 
int fd_
 
pid_t pid_
 
bool use_console_
 

Friends

struct SubprocessSet
 

Detailed Description

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

Definition at line 43 of file subprocess.h.

Constructor & Destructor Documentation

◆ ~Subprocess()

Subprocess::~Subprocess ( )

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

References fd_, Finish(), and pid_.

◆ Subprocess()

Subprocess::Subprocess ( bool  use_console)
private

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

Member Function Documentation

◆ Done()

bool Subprocess::Done ( ) const

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

References fd_.

Referenced by TEST_F().

◆ Finish()

ExitStatus Subprocess::Finish ( )

Returns ExitSuccess on successful process exit, ExitInterrupted if the process was interrupted, ExitFailure if it otherwise failed.

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

References ExitFailure, ExitInterrupted, ExitSuccess, Fatal(), and pid_.

Referenced by TEST_F(), RealCommandRunner::WaitForCommand(), and ~Subprocess().

◆ GetOutput()

const string & Subprocess::GetOutput ( ) const

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

References buf_.

Referenced by TEST_F(), and RealCommandRunner::WaitForCommand().

◆ OnPipeReady()

void Subprocess::OnPipeReady ( )
private

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

References buf_, Fatal(), and fd_.

◆ Start()

bool Subprocess::Start ( struct SubprocessSet set,
const string &  command 
)
private

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

References environ, Fatal(), fd_, pid_, SetCloseOnExec(), and use_console_.

Referenced by SubprocessSet::Add().

Friends And Related Function Documentation

◆ SubprocessSet

friend struct SubprocessSet
friend

Definition at line 77 of file subprocess.h.

Member Data Documentation

◆ buf_

string Subprocess::buf_
private

Definition at line 59 of file subprocess.h.

Referenced by GetOutput(), and OnPipeReady().

◆ fd_

int Subprocess::fd_
private

Definition at line 72 of file subprocess.h.

Referenced by Done(), OnPipeReady(), Start(), and ~Subprocess().

◆ pid_

pid_t Subprocess::pid_
private

Definition at line 73 of file subprocess.h.

Referenced by Finish(), Start(), and ~Subprocess().

◆ use_console_

bool Subprocess::use_console_
private

Definition at line 75 of file subprocess.h.

Referenced by Start().


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