libnick 2025.7.3
A cross-platform base for native Nickvision applications.
|
A managed process. More...
#include <process.h>
Public Member Functions | |
Process (const std::filesystem::path &path, const std::vector< std::string > &args={}, const std::filesystem::path &workingDir={}) | |
Constructs a Process. | |
~Process () | |
Destructs a Process. | |
Events::Event< ProcessExitedEventArgs > & | exited () |
Gets the event for when the process has exited. | |
const std::filesystem::path & | getPath () const |
Gets the path of the process. | |
ProcessState | getState () const |
Gets the state of the proicess. | |
int | getExitCode () const |
Gets the exit code of the process. | |
const std::string & | getOutput () const |
Gets the console output of the process. | |
double | getCPUUsage () const |
Gets the percent of the CPU being used by the process. | |
unsigned long long | getRAMUsage () const |
Gets the amount of RAM being used by the process in bytes. | |
bool | start () |
Starts the process. | |
bool | kill () |
Kills the process. | |
bool | resume () |
Resumes the process. | |
bool | pause () |
Pauses the process. | |
int | waitForExit () |
Waits for the process to exit. | |
bool | send (const std::string &s) |
Sends text to the process' console. | |
bool | sendCommand (std::string s) |
Sends text to the process' console and adds the return characters. |
A managed process.
Nickvision::System::Process::Process | ( | const std::filesystem::path & | path, |
const std::vector< std::string > & | args = {}, | ||
const std::filesystem::path & | workingDir = {} ) |
Constructs a Process.
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 |
std::runtime_error | Thrown if the process could not be created |
Nickvision::System::Process::~Process | ( | ) |
Destructs a Process.
This method will wait for the process to exit if it is still running.
Events::Event< ProcessExitedEventArgs > & Nickvision::System::Process::exited | ( | ) |
Gets the event for when the process has exited.
double Nickvision::System::Process::getCPUUsage | ( | ) | const |
Gets the percent of the CPU being used by the process.
int Nickvision::System::Process::getExitCode | ( | ) | const |
Gets the exit code of the process.
const std::string & Nickvision::System::Process::getOutput | ( | ) | const |
Gets the console output of the process.
const std::filesystem::path & Nickvision::System::Process::getPath | ( | ) | const |
Gets the path of the process.
unsigned long long Nickvision::System::Process::getRAMUsage | ( | ) | const |
Gets the amount of RAM being used by the process in bytes.
ProcessState Nickvision::System::Process::getState | ( | ) | const |
Gets the state of the proicess.
bool Nickvision::System::Process::kill | ( | ) |
Kills the process.
bool Nickvision::System::Process::pause | ( | ) |
Pauses the process.
bool Nickvision::System::Process::resume | ( | ) |
Resumes the process.
bool Nickvision::System::Process::send | ( | const std::string & | s | ) |
Sends text to the process' console.
s | The text to send |
bool Nickvision::System::Process::sendCommand | ( | std::string | s | ) |
Sends text to the process' console and adds the return characters.
s | The command to send |
bool Nickvision::System::Process::start | ( | ) |
Starts the process.
Use Process::resume() to start again a paused process.
int Nickvision::System::Process::waitForExit | ( | ) |