CppCommon
1.0.4.1
C++ Common Library
|
#include <process.h>
Public Member Functions | |
Process (const Process &process) | |
Process (Process &&process) noexcept | |
~Process () | |
Process & | operator= (const Process &process) |
Process & | operator= (Process &&process) noexcept |
uint64_t | pid () const noexcept |
Get the process Id. More... | |
bool | IsRunning () const |
Is the process is running? More... | |
void | Kill () |
Kill the process. More... | |
int | Wait () |
Wait the process to exit. More... | |
int | WaitFor (const Timespan ×pan) |
Wait the process to exit for the given timespan. More... | |
int | WaitUntil (const UtcTimestamp ×tamp) |
Wait the process to exit until the given timestamp. More... | |
void | swap (Process &process) noexcept |
Swap two instances. More... | |
Static Public Member Functions | |
static uint64_t | CurrentProcessId () noexcept |
Get the current process Id. More... | |
static uint64_t | ParentProcessId () noexcept |
Get the parent process Id. More... | |
static Process | CurrentProcess () |
Get the current process. More... | |
static Process | ParentProcess () |
Get the parent process. More... | |
static void | Exit (int result) |
Exit the current process. More... | |
static Process | Execute (const std::string &command, const std::vector< std::string > *arguments=nullptr, const std::map< std::string, std::string > *envars=nullptr, const std::string *directory=nullptr, Pipe *input=nullptr, Pipe *output=nullptr, Pipe *error=nullptr) |
Execute a new process. More... | |
Friends | |
void | swap (Process &process1, Process &process2) noexcept |
Process abstraction.
Process contains different kinds of process manipulation functionality such as retrive the current process Id, execute or terminate one.
Thread-safe.
CppCommon::Process::Process | ( | const Process & | process | ) |
Definition at line 502 of file process.cpp.
|
noexcept |
Definition at line 513 of file process.cpp.
CppCommon::Process::~Process | ( | ) |
Definition at line 518 of file process.cpp.
|
inlinestatic |
|
staticnoexcept |
Get the current process Id.
Definition at line 544 of file process.cpp.
|
static |
Execute a new process.
If input/output/error communication pipe is not provided then new process will use equivalent standard stream of the parent process.
command | - Command to execute |
arguments | - Pointer to arguments vector (default is nullptr) |
envars | - Pointer to environment variables map (default is nullptr) |
directory | - Initial working directory (default is nullptr) |
input | - Input communication pipe (default is nullptr) |
output | - Output communication pipe (default is nullptr) |
error | - Error communication pipe (default is nullptr) |
Definition at line 549 of file process.cpp.
|
static |
Exit the current process.
result | - Result is returned to the parent |
Definition at line 547 of file process.cpp.
bool CppCommon::Process::IsRunning | ( | ) | const |
Is the process is running?
Definition at line 538 of file process.cpp.
void CppCommon::Process::Kill | ( | ) |
Kill the process.
Definition at line 540 of file process.cpp.
Definition at line 524 of file process.cpp.
Definition at line 530 of file process.cpp.
|
inlinestatic |
|
staticnoexcept |
Get the parent process Id.
Definition at line 545 of file process.cpp.
|
noexcept |
Get the process Id.
Definition at line 536 of file process.cpp.
|
noexcept |
Swap two instances.
Definition at line 554 of file process.cpp.
int CppCommon::Process::Wait | ( | ) |
Wait the process to exit.
Will block.
Definition at line 541 of file process.cpp.
int CppCommon::Process::WaitFor | ( | const Timespan & | timespan | ) |
Wait the process to exit for the given timespan.
Will block for the given timespan in the worst case.
timespan | - Timespan to wait for the process |
Definition at line 542 of file process.cpp.
|
inline |
Definition at line 21 of file process.inl.