process-cpp 3.0.0
A simple convenience library for handling processes in C++11.
|
Namespaces | |
namespace | backtrace |
namespace | exit |
namespace | linux |
namespace | this_process |
namespace | wait |
Classes | |
class | ChildProcess |
The Process class models a child process of this process. More... | |
class | Process |
The Process class models a process and possible operations on it. More... | |
class | ProcessGroup |
The ProcessGroup class models a signalable group of process. More... | |
class | Signalable |
The Signalable class abstracts the ability of an entity to be delivered a posix signal. More... | |
class | SignalTrap |
The SignalTrap class encapsulates functionality to trap and handle signals. More... | |
Enumerations | |
enum class | Signal { unknown = 0 , sig_hup = SIGHUP , sig_int = SIGINT , sig_quit = SIGQUIT , sig_ill = SIGILL , sig_abrt = SIGABRT , sig_fpe = SIGFPE , sig_kill = SIGKILL , sig_segv = SIGSEGV , sig_pipe = SIGPIPE , sig_alrm = SIGALRM , sig_term = SIGTERM , sig_usr1 = SIGUSR1 , sig_usr2 = SIGUSR2 , sig_chld = SIGCHLD , sig_cont = SIGCONT , sig_stop = SIGSTOP , sig_tstp = SIGTSTP , sig_ttin = SIGTTIN , sig_ttou = SIGTTOU } |
The Signal enum collects the most common POSIX signals. More... | |
enum class | StandardStream : std::uint8_t { empty = 0 , stdin = 1 << 0 , stdout = 1 << 1 , stderr = 1 << 2 } |
The StandardStream enum wraps the POSIX standard streams. More... | |
Functions | |
CORE_POSIX_DLL_PUBLIC ChildProcess | exec (const std::string &fn, const std::vector< std::string > &argv, const std::map< std::string, std::string > &env, const StandardStream &flags) |
exec execve's the executable with the provided arguments and environment. | |
CORE_POSIX_DLL_PUBLIC ChildProcess | exec (const std::string &fn, const std::vector< std::string > &argv, const std::map< std::string, std::string > &env, const StandardStream &flags, const std::function< void()> &child_setup) |
exec execve's the executable with the provided arguments and environment. | |
CORE_POSIX_DLL_PUBLIC ChildProcess | fork (const std::function< posix::exit::Status()> &main, const StandardStream &flags) |
fork forks a new process and executes the provided main function in the newly forked process. | |
CORE_POSIX_DLL_PUBLIC ChildProcess | vfork (const std::function< posix::exit::Status()> &main, const StandardStream &flags) |
fork vforks a new process and executes the provided main function in the newly forked process. | |
CORE_POSIX_DLL_PUBLIC std::shared_ptr< SignalTrap > | trap_signals_for_process (std::initializer_list< core::posix::Signal > blocked_signals) |
Traps the specified signals for the entire process. | |
CORE_POSIX_DLL_PUBLIC std::shared_ptr< SignalTrap > | trap_signals_for_all_subsequent_threads (std::initializer_list< core::posix::Signal > blocked_signals) |
Traps the specified signals for the current thread, and inherits the respective signal mask to all child-threads. | |
CORE_POSIX_DLL_PUBLIC StandardStream | operator| (StandardStream l, StandardStream r) |
CORE_POSIX_DLL_PUBLIC StandardStream | operator& (StandardStream l, StandardStream r) |
bool | is_child (pid_t pid) |
|
strong |
|
strong |
The StandardStream enum wraps the POSIX standard streams.
Enumerator | |
---|---|
empty | |
stdin | |
stdout | |
stderr |
Definition at line 38 of file standard_stream.h.
ChildProcess core::posix::exec | ( | const std::string & | fn, |
const std::vector< std::string > & | argv, | ||
const std::map< std::string, std::string > & | env, | ||
const StandardStream & | flags ) |
exec execve's the executable with the provided arguments and environment.
std::system_error | in case of errors. |
fn | The executable to run. |
argv | Vector of command line arguments |
env | Environment that the new process should run under |
flags | Specifies which standard streams should be redirected. |
Definition at line 33 of file exec.cpp.
References exec().
Referenced by exec(), TEST(), TEST(), TEST(), and TEST().
ChildProcess core::posix::exec | ( | const std::string & | fn, |
const std::vector< std::string > & | argv, | ||
const std::map< std::string, std::string > & | env, | ||
const StandardStream & | flags, | ||
const std::function< void()> & | child_setup ) |
exec execve's the executable with the provided arguments and environment.
std::system_error | in case of errors. |
fn | The executable to run. |
argv | Vector of command line arguments |
env | Environment that the new process should run under |
flags | Specifies which standard streams should be redirected. |
child_setup | Function to run in the child just before exec(). |
Definition at line 42 of file exec.cpp.
References fork().
ChildProcess core::posix::fork | ( | const std::function< posix::exit::Status()> & | main, |
const StandardStream & | flags ) |
fork forks a new process and executes the provided main function in the newly forked process.
std::system_error | in case of errors. |
[in] | main | The main function of the newly forked process. |
[in] | flags | Specify which standard streams should be redirected to the parent process. |
Definition at line 57 of file fork.cpp.
Referenced by exec(), core::posix::ChildProcess::fork, core::testing::fork_and_run(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST_F().
bool core::posix::is_child | ( | pid_t | pid | ) |
Definition at line 55 of file fork.cpp.
Referenced by core::posix::ChildProcess::fork, and core::posix::ChildProcess::vfork.
StandardStream core::posix::operator& | ( | StandardStream | l, |
StandardStream | r ) |
Definition at line 30 of file standard_stream.cpp.
StandardStream core::posix::operator| | ( | StandardStream | l, |
StandardStream | r ) |
Definition at line 25 of file standard_stream.cpp.
std::shared_ptr< core::posix::SignalTrap > core::posix::trap_signals_for_all_subsequent_threads | ( | std::initializer_list< core::posix::Signal > | blocked_signals | ) |
Traps the specified signals for the current thread, and inherits the respective signal mask to all child-threads.
Definition at line 210 of file signal.cpp.
References impl::SignalTrap::thread.
Referenced by TESTP().
std::shared_ptr< core::posix::SignalTrap > core::posix::trap_signals_for_process | ( | std::initializer_list< core::posix::Signal > | blocked_signals | ) |
Traps the specified signals for the entire process.
Definition at line 202 of file signal.cpp.
References impl::SignalTrap::process.
ChildProcess core::posix::vfork | ( | const std::function< posix::exit::Status()> & | main, |
const StandardStream & | flags ) |
fork vforks a new process and executes the provided main function in the newly forked process.
std::system_error | in case of errors. |
[in] | main | The main function of the newly forked process. |
[in] | flags | Specify which standard streams should be redirected to the parent process. |
Definition at line 125 of file fork.cpp.
Referenced by core::posix::ChildProcess::vfork.