|
process-cpp
3.0.0
A simple convenience library for handling processes in C++11.
|
Namespaces | |
| backtrace | |
| exit | |
| linux | |
| this_process | |
| 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 | Signal { Signal::unknown = 0, Signal::sig_hup = SIGHUP, Signal::sig_int = SIGINT, Signal::sig_quit = SIGQUIT, Signal::sig_ill = SIGILL, Signal::sig_abrt = SIGABRT, Signal::sig_fpe = SIGFPE, Signal::sig_kill = SIGKILL, Signal::sig_segv = SIGSEGV, Signal::sig_pipe = SIGPIPE, Signal::sig_alrm = SIGALRM, Signal::sig_term = SIGTERM, Signal::sig_usr1 = SIGUSR1, Signal::sig_usr2 = SIGUSR2, Signal::sig_chld = SIGCHLD, Signal::sig_cont = SIGCONT, Signal::sig_stop = SIGSTOP, Signal::sig_tstp = SIGTSTP, Signal::sig_ttin = SIGTTIN, Signal::sig_ttou = SIGTTOU } |
| The Signal enum collects the most common POSIX signals. More... | |
| enum | StandardStream : std::uint8_t { StandardStream::empty = 0, StandardStream::stdin = 1 << 0, StandardStream::stdout = 1 << 1, StandardStream::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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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 33 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.
Referenced by 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().
Here is the call graph for this function:| 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.
References core::posix::this_process::cerr(), is_child(), main(), stderr, stdin, stdout, and core::posix::exit::success.
Referenced by exec(), core::testing::fork_and_run(), TEST(), and TEST_F().
Here is the call graph for this function:| bool core::posix::is_child | ( | pid_t | pid | ) |
| 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 122 of file fork.cpp.
References core::posix::this_process::cerr(), is_child(), main(), stderr, stdin, stdout, and core::posix::exit::success.
Here is the call graph for this function: