process-cpp  3.0.0
A simple convenience library for handling processes in C++11.
core::testing Namespace Reference

Classes

class  CrossProcessSync
 A cross-process synchronization primitive that supports simple wait-condition-like scenarios. More...
 

Enumerations

enum  ForkAndRunResult {
  ForkAndRunResult::empty = 0,
  ForkAndRunResult::client_failed = 1 << 0,
  ForkAndRunResult::service_failed = 1 << 1
}
 The ForkAndRunResult enum models the different failure modes of fork_and_run. More...
 

Functions

CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator| (ForkAndRunResult lhs, ForkAndRunResult rhs)
 
CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator& (ForkAndRunResult lhs, ForkAndRunResult rhs)
 
CORE_POSIX_DLL_PUBLIC ForkAndRunResult fork_and_run (const std::function< core::posix::exit::Status()> &service, const std::function< core::posix::exit::Status()> &client)
 Forks two processes for both the service and the client. More...
 

Enumeration Type Documentation

The ForkAndRunResult enum models the different failure modes of fork_and_run.

Enumerator
empty 

Special value indicating no bit being set.

client_failed 

The client failed.

service_failed 

The service failed.

Definition at line 34 of file fork_and_run.h.

Function Documentation

core::testing::ForkAndRunResult core::testing::fork_and_run ( const std::function< core::posix::exit::Status()> &  service,
const std::function< core::posix::exit::Status()> &  client 
)

Forks two processes for both the service and the client.

The function does the following:

  • Forks a process for the service and runs the respective closure.
  • Forks a process for the client and runs the respective closure.
  • After the client has finished, the service is signalled with sigterm.
Exceptions
std::system_errorif an error occured during process interaction.
std::runtime_errorfor signalling all other error conditions.
Parameters
[in]serviceThe service to be executed in a child process.
[in]clientThe client to be executed in a child process.
Returns
ForkAndRunResult indicating if either of service or client failed.

Definition at line 41 of file fork_and_run.cpp.

References client_failed, empty, core::posix::empty, core::posix::wait::Result::exited, core::posix::exit::failure, core::posix::fork(), service_failed, core::posix::sig_term, and core::posix::wait::untraced.

Referenced by TEST().

+ Here is the call graph for this function:

core::testing::ForkAndRunResult core::testing::operator& ( ForkAndRunResult  lhs,
ForkAndRunResult  rhs 
)

Definition at line 33 of file fork_and_run.cpp.

core::testing::ForkAndRunResult core::testing::operator| ( ForkAndRunResult  lhs,
ForkAndRunResult  rhs 
)

Definition at line 25 of file fork_and_run.cpp.