AsmGrader 0.0.0
Loading...
Searching...
No Matches
asmgrader::Subprocess Class Reference

#include <subprocess.hpp>

Inheritance diagram for asmgrader::Subprocess:
[legend]

Public Member Functions

 Subprocess (std::string exec, std::vector< std::string > args)
 Creates a sub (child) process by running exec with args ENV variables remain as default for for the child process.
 
virtual ~Subprocess ()
 
 Subprocess (Subprocess &&) noexcept
 
Subprocessoperator= (Subprocess &&) noexcept
 
template<typename Rep , typename Period >
Result< std::string > read_stdout (const std::chrono::duration< Rep, Period > &timeout)
 
Result< std::string > read_stdout ()
 
const std::string & get_full_stdout ()
 Get all stdout since the program has launched.
 
Result< void > send_stdin (const std::string &str)
 
virtual Result< void > start ()
 
int wait_for_exit ()
 
virtual Result< int > wait_for_exit (std::chrono::microseconds timeout)
 
bool is_alive () const
 Whether child process is alive.
 
Result< void > close_pipes ()
 Close stdout and stdin pipes to child Useful for when the child is blocking on a read to stdin.
 
pid_t get_pid () const
 
std::optional< int > get_exit_code () const
 
virtual Result< void > kill ()
 Manually kill subprocess with SIGKILL.
 
virtual Result< void > restart ()
 

Protected Member Functions

 Subprocess ()=default
 
virtual Result< void > create (const std::string &exec, const std::vector< std::string > &args)
 
virtual Result< void > init_child ()
 
virtual Result< void > init_parent ()
 

Constructor & Destructor Documentation

◆ Subprocess() [1/3]

asmgrader::Subprocess::Subprocess ( std::string exec,
std::vector< std::string > args )
explicit

Creates a sub (child) process by running exec with args ENV variables remain as default for for the child process.

◆ ~Subprocess()

asmgrader::Subprocess::~Subprocess ( )
virtual

◆ Subprocess() [2/3]

asmgrader::Subprocess::Subprocess ( Subprocess && other)
noexcept

◆ Subprocess() [3/3]

asmgrader::Subprocess::Subprocess ( )
protecteddefault

Member Function Documentation

◆ close_pipes()

Result< void > asmgrader::Subprocess::close_pipes ( )

Close stdout and stdin pipes to child Useful for when the child is blocking on a read to stdin.

◆ create()

Result< void > asmgrader::Subprocess::create ( const std::string & exec,
const std::vector< std::string > & args )
protectedvirtual

◆ get_exit_code()

std::optional< int > asmgrader::Subprocess::get_exit_code ( ) const
inline

◆ get_full_stdout()

const std::string & asmgrader::Subprocess::get_full_stdout ( )

Get all stdout since the program has launched.

◆ get_pid()

pid_t asmgrader::Subprocess::get_pid ( ) const
inline

◆ init_child()

Result< void > asmgrader::Subprocess::init_child ( )
protectedvirtual

◆ init_parent()

Result< void > asmgrader::Subprocess::init_parent ( )
protectedvirtual

◆ is_alive()

bool asmgrader::Subprocess::is_alive ( ) const

Whether child process is alive.

◆ kill()

Result< void > asmgrader::Subprocess::kill ( )
virtual

Manually kill subprocess with SIGKILL.

◆ operator=()

Subprocess & asmgrader::Subprocess::operator= ( Subprocess && rhs)
noexcept

◆ read_stdout() [1/2]

Result< std::string > asmgrader::Subprocess::read_stdout ( )

◆ read_stdout() [2/2]

template<typename Rep , typename Period >
Result< std::string > asmgrader::Subprocess::read_stdout ( const std::chrono::duration< Rep, Period > & timeout)
inline

◆ restart()

Result< void > asmgrader::Subprocess::restart ( )
virtual

◆ send_stdin()

Result< void > asmgrader::Subprocess::send_stdin ( const std::string & str)

◆ start()

Result< void > asmgrader::Subprocess::start ( )
virtual

◆ wait_for_exit() [1/2]

int asmgrader::Subprocess::wait_for_exit ( )

◆ wait_for_exit() [2/2]

Result< int > asmgrader::Subprocess::wait_for_exit ( std::chrono::microseconds timeout)
virtual

Reimplemented in asmgrader::TracedSubprocess.


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