A managed process.
More...
#include <process.h>
|
| Process (const std::filesystem::path &path, const std::vector< std::string > &args={}, const std::filesystem::path &workingDir={}) |
| Constructs a Process.
|
|
| ~Process () noexcept |
| Destructs a Process.
|
|
Events::Event< ProcessExitedEventArgs > & | exited () noexcept |
| Gets the event for when the process has exited.
|
|
const std::filesystem::path & | getPath () const noexcept |
| Gets the path of the process.
|
|
ProcessState | getState () const noexcept |
| Gets the state of the proicess.
|
|
int | getExitCode () const noexcept |
| Gets the exit code of the process.
|
|
const std::string & | getOutput () const noexcept |
| Gets the console output of the process.
|
|
double | getCPUUsage () const noexcept |
| Gets the percent of the CPU being used by the process.
|
|
unsigned long long | getRAMUsage () const noexcept |
| Gets the amount of RAM being used by the process in bytes.
|
|
bool | start () noexcept |
| Starts the process.
|
|
bool | kill () noexcept |
| Kills the process.
|
|
bool | resume () noexcept |
| Resumes the process.
|
|
bool | pause () noexcept |
| Pauses the process.
|
|
int | waitForExit () noexcept |
| Waits for the process to exit.
|
|
bool | send (const std::string &s) noexcept |
| Sends text to the process' console.
|
|
bool | sendCommand (std::string s) noexcept |
| Sends text to the process' console and adds the return characters.
|
|
◆ Process()
Nickvision::System::Process::Process |
( |
const std::filesystem::path & | path, |
|
|
const std::vector< std::string > & | args = {}, |
|
|
const std::filesystem::path & | workingDir = {} ) |
Constructs a Process.
- Parameters
-
path | The path of the process to execute |
args | The arguments to pass to the process |
workingDir | An optional working directory to use for a process |
- Exceptions
-
std::runtime_error | Thrown if the process could not be created |
◆ ~Process()
Nickvision::System::Process::~Process |
( |
| ) |
|
|
noexcept |
Destructs a Process.
This method will wait for the process to exit if it is still running.
◆ exited()
Gets the event for when the process has exited.
- Returns
- The process exited event
◆ getCPUUsage()
double Nickvision::System::Process::getCPUUsage |
( |
| ) |
const |
|
noexcept |
Gets the percent of the CPU being used by the process.
- Returns
- The CPU usage of the process
◆ getExitCode()
int Nickvision::System::Process::getExitCode |
( |
| ) |
const |
|
noexcept |
Gets the exit code of the process.
- Returns
- The exit code of the process. -1 if the process has not completed
◆ getOutput()
const std::string & Nickvision::System::Process::getOutput |
( |
| ) |
const |
|
noexcept |
Gets the console output of the process.
- Returns
- The console output of the process. Empty if the process has not completed
◆ getPath()
const std::filesystem::path & Nickvision::System::Process::getPath |
( |
| ) |
const |
|
noexcept |
Gets the path of the process.
- Returns
- The path of the process
◆ getRAMUsage()
unsigned long long Nickvision::System::Process::getRAMUsage |
( |
| ) |
const |
|
noexcept |
Gets the amount of RAM being used by the process in bytes.
- Returns
- The amount of RAM used by the process
◆ getState()
ProcessState Nickvision::System::Process::getState |
( |
| ) |
const |
|
noexcept |
Gets the state of the proicess.
- Returns
- The state of the process.
◆ kill()
bool Nickvision::System::Process::kill |
( |
| ) |
|
|
noexcept |
Kills the process.
- Returns
- True if the process was killed, else false
◆ pause()
bool Nickvision::System::Process::pause |
( |
| ) |
|
|
noexcept |
Pauses the process.
- Returns
- True if the process was paused, else false
◆ resume()
bool Nickvision::System::Process::resume |
( |
| ) |
|
|
noexcept |
Resumes the process.
- Returns
- True if the process was resumed, else false
◆ send()
bool Nickvision::System::Process::send |
( |
const std::string & | s | ) |
|
|
noexcept |
Sends text to the process' console.
- Parameters
-
- Returns
- True if the text is sent, else false
◆ sendCommand()
bool Nickvision::System::Process::sendCommand |
( |
std::string | s | ) |
|
|
noexcept |
Sends text to the process' console and adds the return characters.
- Parameters
-
- Returns
- True if the command is sent, else false
◆ start()
bool Nickvision::System::Process::start |
( |
| ) |
|
|
noexcept |
Starts the process.
Use Process::resume() to start again a paused process.
- Returns
- True if the process was started, else false
◆ waitForExit()
int Nickvision::System::Process::waitForExit |
( |
| ) |
|
|
noexcept |
Waits for the process to exit.
This function will block until the process has exited.
Make sure to call start() / resume() before calling this function.
- Returns
- The exit code of the process
The documentation for this class was generated from the following file: