Convenience wrapper for forking processes.
More...
#include <Fork.hpp>
Convenience wrapper for forking processes.
◆ checkForTermination() [1/2]
Check the process for termination without blocking.
If the pid is invalid, an empty termination report is returned.
If the process with the specified id has not terminated, an empty termination report is returned.
- Parameters
-
- Returns
- a termination report
- Exceptions
-
WaitException | if the waitid call failed |
◆ checkForTermination() [2/2]
static std::vector<TerminationReport> checkForTermination |
( |
const std::vector< int > & |
pids | ) |
|
|
inlinestatic |
Check without blocking the supplied processes for termination.
- Parameters
-
- Returns
- a vector of termination reports for the pids that terminated.
- Exceptions
-
WaitException | if the waitid call failed |
◆ forkSupported()
static bool forkSupported |
( |
| ) |
|
|
inlinestatic |
Determine whether forking is support on this platform.
◆ performFork() [1/2]
static int performFork |
( |
const std::function< int()> & |
function, |
|
|
bool |
exitChild |
|
) |
| |
|
inlinestatic |
Perform a fork operator and run the supplied function for the child.
The child process will exit when the function returns if exitChild is set to true. Otherwise, the child will return and the caller will need to handle child termination.
- Parameters
-
function | the function to run in the child process |
exitChild | if set to true, _Exit(int) is called with the the exit state of the function |
- Returns
- the child pid for the parent process, the exit state of the function for the child process if it returns
- Exceptions
-
ForkException | if the fork call failed |
◆ performFork() [2/2]
static int performFork |
( |
const std::function< int()> & |
function | ) |
|
|
inlinestatic |
Perform a fork operator and run the supplied function for the child.
The child will return when the function has completed and the caller will need to handle child termination.
This version does not require a function that returns an integer.
- Parameters
-
function | the function to run in the child process |
- Returns
- the child pid for the parent process and zero for the child process
- Exceptions
-
ForkException | if the fork call failed |
◆ terminateProcess()
Terminate the child process if it is running.
If the process has not terminated, terminate it and return an empty termination report. If the pid is invalid, an empty termination report is returned.
- Parameters
-
- Returns
- a termination report
- Exceptions
-
WaitException | if the waitid call failed |
◆ waitOnProcess()
Wait on a process until the process terminates.
If the pid is invalid, an empty termination report is returned.
- Parameters
-
- Returns
- a termination report
- Exceptions
-
WaitException | if the waitid call failed |
The documentation for this class was generated from the following file: