UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMonitoredProcess Class Reference

#include <MonitoredProcess.h>

+ Inheritance diagram for FMonitoredProcess:

Public Member Functions

CORE_API FMonitoredProcess (const FString &InURL, const FString &InParams, bool InHidden, bool InCreatePipes=true)
 
CORE_API FMonitoredProcess (const FString &InURL, const FString &InParams, const FString &InWorkingDir, bool InHidden, bool InCreatePipes=true)
 
virtual CORE_API ~FMonitoredProcess ()
 
void Cancel (bool InKillTree=false)
 
CORE_API FTimespan GetDuration () const
 
FProcHandle GetProcessHandle () const
 
FString GetCommandline () const
 
CORE_API bool Update ()
 
virtual CORE_API bool Launch ()
 
void SetSleepInterval (float InSleepInterval)
 
FSimpleDelegateOnCanceled ()
 
FOnMonitoredProcessCompletedOnCompleted ()
 
FOnMonitoredProcessOutputOnOutput ()
 
CORE_API int GetReturnCode () const
 
CORE_API const FString & GetFullOutputWithoutDelegate () const
 
virtual bool Init () override
 
virtual CORE_API uint32 Run () override
 
virtual void Stop () override
 
virtual void Exit () override
 
virtual FSingleThreadRunnableGetSingleThreadInterface () override
 
- Public Member Functions inherited from FRunnable
virtual ~FRunnable ()
 

Protected Member Functions

CORE_API void Tick () override
 
CORE_API void ProcessOutput (const FString &Output)
 
CORE_API void TickInternal ()
 

Protected Attributes

TAtomic< boolCanceling = false
 
TAtomic< FDateTimeEndTime
 
bool Hidden = false
 
TAtomic< boolKillTree = false
 
FString Params
 
FProcHandle ProcessHandle
 
voidReadPipe = nullptr
 
TAtomic< int > ReturnCode = 0
 
TAtomic< FDateTimeStartTime { 0 }
 
FRunnableThreadThread = nullptr
 
TAtomic< boolbIsRunning
 
FString URL
 
FString WorkingDir
 
voidWritePipe = nullptr
 
bool bCreatePipes = false
 
float SleepInterval = 0.01f
 
FString OutputBuffer
 
FSimpleDelegate CanceledDelegate
 
FOnMonitoredProcessCompleted CompletedDelegate
 
FOnMonitoredProcessOutput OutputDelegate
 

Detailed Description

Implements an external process that can be monitored.

Constructor & Destructor Documentation

◆ FMonitoredProcess() [1/2]

FMonitoredProcess::FMonitoredProcess ( const FString &  InURL,
const FString &  InParams,
bool  InHidden,
bool  InCreatePipes = true 
)

Creates a new monitored process.

Parameters
InURLThe URL of the executable to launch.
InParamsThe command line parameters.
InHiddenWhether the window of the process should be hidden.
InCreatePipesWhether the output should be redirected to the caller.

◆ FMonitoredProcess() [2/2]

FMonitoredProcess::FMonitoredProcess ( const FString &  InURL,
const FString &  InParams,
const FString &  InWorkingDir,
bool  InHidden,
bool  InCreatePipes = true 
)

Creates a new monitored process.

Parameters
InURLThe URL of the executable to launch.
InParamsThe command line parameters.
InHiddenWhether the window of the process should be hidden.
InWorkingDirThe URL of the working dir where the executable should launch.
InCreatePipesWhether the output should be redirected to the caller.

◆ ~FMonitoredProcess()

FMonitoredProcess::~FMonitoredProcess ( )
virtual

Destructor.

Member Function Documentation

◆ Cancel()

void FMonitoredProcess::Cancel ( bool  InKillTree = false)
inline

Cancels the process.

Parameters
InKillTreeWhether to kill the entire process tree when canceling this process.

◆ Exit()

virtual void FMonitoredProcess::Exit ( void  )
inlineoverridevirtual

Exits the runnable object.

Called in the context of the aggregating thread to perform any cleanup.

See also
Init, Run, Stop

Reimplemented from FRunnable.

◆ GetCommandline()

FString FMonitoredProcess::GetCommandline ( ) const
inline

Returns the commandline of the process which will be executed if Launch is called

◆ GetDuration()

FTimespan FMonitoredProcess::GetDuration ( ) const

Gets the duration of time that the task has been running.

Returns
Time duration.

◆ GetFullOutputWithoutDelegate()

const FString & FMonitoredProcess::GetFullOutputWithoutDelegate ( ) const

Returns the full output, wihtout needing to hookup a delegate and buffer it externally. Note that if OutputDelegate is bound, this will not have the entire output

◆ GetProcessHandle()

FProcHandle FMonitoredProcess::GetProcessHandle ( ) const
inline

Gets the Process Handle. The instance can be invalid if the process was not created.

Returns
The Process Handle

◆ GetReturnCode()

int FMonitoredProcess::GetReturnCode ( ) const

Returns the return code from the exited process

Returns
Process return code

◆ GetSingleThreadInterface()

virtual FSingleThreadRunnable * FMonitoredProcess::GetSingleThreadInterface ( )
inlineoverridevirtual

Gets single thread interface pointer used for ticking this runnable when multi-threading is disabled. If the interface is not implemented, this runnable will not be ticked when FPlatformProcess::SupportsMultithreading() is false.

Returns
Pointer to the single thread interface or nullptr if not implemented.

Reimplemented from FRunnable.

◆ Init()

virtual bool FMonitoredProcess::Init ( void  )
inlineoverridevirtual

Initializes the runnable object.

This method is called in the context of the thread object that aggregates this, not the thread that passes this runnable to a new thread.

Returns
True if initialization was successful, false otherwise
See also
Run, Stop, Exit

Reimplemented from FRunnable.

◆ Launch()

bool FMonitoredProcess::Launch ( )
virtual

Launches the process.

Reimplemented in FSerializedUATProcess.

◆ OnCanceled()

FSimpleDelegate & FMonitoredProcess::OnCanceled ( )
inline

Returns a delegate that is executed when the process has been canceled.

Returns
The delegate.

◆ OnCompleted()

FOnMonitoredProcessCompleted & FMonitoredProcess::OnCompleted ( )
inline

Returns a delegate that is executed when a monitored process completed.

Returns
The delegate.

◆ OnOutput()

FOnMonitoredProcessOutput & FMonitoredProcess::OnOutput ( )
inline

Returns a delegate that is executed when a monitored process produces output.

Returns
The delegate.

◆ ProcessOutput()

void FMonitoredProcess::ProcessOutput ( const FString &  Output)
protected

Processes the given output string.

Parameters
OutputThe output string to process.

◆ Run()

uint32 FMonitoredProcess::Run ( )
overridevirtual

Runs the runnable object.

This is where all per object thread work is done. This is only called if the initialization was successful.

Returns
The exit code of the runnable object
See also
Init, Stop, Exit

Implements FRunnable.

◆ SetSleepInterval()

void FMonitoredProcess::SetSleepInterval ( float  InSleepInterval)
inline

Sets the sleep interval to be used in the main thread loop.

Parameters
InSleepIntervalThe Sleep interval to use.

◆ Stop()

virtual void FMonitoredProcess::Stop ( void  )
inlineoverridevirtual

Stops the runnable object.

This is called if a thread is requested to terminate early.

See also
Init, Run, Exit

Reimplemented from FRunnable.

◆ Tick()

void FMonitoredProcess::Tick ( )
overrideprotectedvirtual

◆ TickInternal()

void FMonitoredProcess::TickInternal ( )
protected

◆ Update()

bool FMonitoredProcess::Update ( )

Checks whether the process is still running. In single threaded mode, this will tick the thread processing

Returns
true if the process is running, false otherwise.

Member Data Documentation

◆ bCreatePipes

bool FMonitoredProcess::bCreatePipes = false
protected

◆ bIsRunning

TAtomic<bool> FMonitoredProcess::bIsRunning
protected

◆ CanceledDelegate

FSimpleDelegate FMonitoredProcess::CanceledDelegate
protected

◆ Canceling

TAtomic<bool> FMonitoredProcess::Canceling = false
protected

◆ CompletedDelegate

FOnMonitoredProcessCompleted FMonitoredProcess::CompletedDelegate
protected

◆ EndTime

TAtomic<FDateTime> FMonitoredProcess::EndTime
protected

◆ Hidden

bool FMonitoredProcess::Hidden = false
protected

◆ KillTree

TAtomic<bool> FMonitoredProcess::KillTree = false
protected

◆ OutputBuffer

FString FMonitoredProcess::OutputBuffer
protected

◆ OutputDelegate

FOnMonitoredProcessOutput FMonitoredProcess::OutputDelegate
protected

◆ Params

FString FMonitoredProcess::Params
protected

◆ ProcessHandle

FProcHandle FMonitoredProcess::ProcessHandle
protected

◆ ReadPipe

void* FMonitoredProcess::ReadPipe = nullptr
protected

◆ ReturnCode

TAtomic<int> FMonitoredProcess::ReturnCode = 0
protected

◆ SleepInterval

float FMonitoredProcess::SleepInterval = 0.01f
protected

◆ StartTime

TAtomic<FDateTime> FMonitoredProcess::StartTime { 0 }
protected

◆ Thread

FRunnableThread* FMonitoredProcess::Thread = nullptr
protected

◆ URL

FString FMonitoredProcess::URL
protected

◆ WorkingDir

FString FMonitoredProcess::WorkingDir
protected

◆ WritePipe

void* FMonitoredProcess::WritePipe = nullptr
protected

The documentation for this class was generated from the following files: