PProcess Class Reference

Detailed Description

The PProcess class is a toolbox to ease process spawning and management.

Definition at line 28 of file PProcess.h.

#include <PProcess.h>

Member Enumeration Documentation

◆ EExitStatus

EExitStatus describes all the different statuses of a PProcess.

Enumerator
E_NORMAL_EXIT 

The process exited normally.

E_CRASH 

The process crashed.

Definition at line 44 of file PProcess.h.

◆ EProcessState

EProcessState describes all the different states of a PProcess.

Enumerator
E_NOT_RUNNING 

The process is not running.

E_STARTING 

The process is starting.

E_RUNNING 

The process is running.

Definition at line 34 of file PProcess.h.

Constructor & Destructor Documentation

◆ PProcess()

PProcess::PProcess ( )

Constructs an empty PProcess object.

◆ ~PProcess()

virtual PProcess::~PProcess ( )
virtual

Destroys this object.

Member Function Documentation

◆ GetCommand()

const PString& PProcess::GetCommand ( ) const

Returns the full command-line of this process, i.e.

including command-line parameters.

◆ GetErrorOutput()

PString PProcess::GetErrorOutput ( )

Returns all the output of the process so far to the standard error.

◆ GetExitCode()

PResult PProcess::GetExitCode ( papillon::int32 &  exitCode) const

Returns the exit code of the process.

Returns
PResult::C_OK if the process has exited and there is a valid exit code to report, PResult::Error otherwise.

◆ GetExitStatus()

PResult PProcess::GetExitStatus ( PProcess::EExitStatus exitStatus) const

Returns the exit status of the process, i.e.

graceful exit or crash.

Returns
PResult::C_OK if the process has exited and there is a valid exit status to report, PResult::Error otherwise.

◆ GetId()

papillon::int32 PProcess::GetId ( ) const

Returns the ID of this process.

◆ GetName()

PString PProcess::GetName ( ) const

Returns the name of this process as a PString.

◆ GetProcessEnvironment()

PResult PProcess::GetProcessEnvironment ( PStringList environment)

Returns the environment as a PStringList containing parameter=value pairs.

◆ GetProcessId()

papillon::int64 PProcess::GetProcessId ( ) const

Returns the operating system level process ID of this process.

◆ GetStandardOutput()

PString PProcess::GetStandardOutput ( )

Returns all the output of the process so far to the standard output.

◆ GetState()

EProcessState PProcess::GetState ( ) const

Returns the process state, see EProcessState.

◆ GetStateAsString()

const PString& PProcess::GetStateAsString ( ) const

Returns the process sate, i.e.

EProcessState, as a PString.

◆ GetWorkingDirectory()

PString PProcess::GetWorkingDirectory ( ) const

Returns the working directory of this process.

◆ IsCrashed()

bool PProcess::IsCrashed ( ) const

Returns true if the process was crashed.

◆ IsFinished()

bool PProcess::IsFinished ( ) const

Returns true if the process has been finished running and exited gracefully.

◆ IsRunning()

bool PProcess::IsRunning ( ) const

Returns true if the process has been running.

◆ Kill()

void PProcess::Kill ( )

Kills the process.

◆ Restart()

void PProcess::Restart ( )

Restarts the process.

◆ SetId()

void PProcess::SetId ( papillon::int32  id)

Assigns an ID to this process.

◆ SetName()

void PProcess::SetName ( const PString name)

Gives a name to this process.

◆ SetProcessEnvironment()

void PProcess::SetProcessEnvironment ( const PString parameter,
const PString value,
bool  replaceExisting = true 
)

Updates the environment of this process with given parameter=value pair.

◆ SetWorkingDirectory()

void PProcess::SetWorkingDirectory ( const PString directory)

Sets the working directory of this process with given value.

◆ Start()

PResult PProcess::Start ( const PString command)

Spawns a process with given command-line.

◆ Wait()

void PProcess::Wait ( )

This is a blocking call that returns when the spawned process is terminated.

Note that the exit status and the exit code will be available only after this method returns.