FMonitoredProcess

Implements an external process that can be monitored.

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Misc/MonitoredProcess.h

Include

#include "Misc/MonitoredProcess.h"

Syntax

class FMonitoredProcess :
    public FRunnable,
    private FSingleThreadRunnable

Remarks

Implements an external process that can be monitored.

Variables

Name Description

Protected variable

bool

 

bCreatePipes

Holds if we should create pipes.

Protected variable

bool

 

bIsRunning

Is the thread running?

Protected variable

FSimpleDelegate

 

CanceledDelegate

Holds a delegate that is executed when the process has been canceled. */.

Protected variable

bool

 

Canceling

Whether the process is being canceled. */.

Protected variable

FOnMonitoredPro...

 

CompletedDelegate

Holds a delegate that is executed when a monitored process completed. */.

Protected variable

FDateTime

 

EndTime

Holds the time at which the process ended. */.

Protected variable

bool

 

Hidden

Whether the window of the process should be hidden. */.

Protected variable

bool

 

KillTree

Whether to kill the entire process tree when cancelling this process. */.

Protected variable

FString

 

OutputBuffer

Buffered output text which does not contain a newline.

Protected variable

FOnMonitoredPro...

 

OutputDelegate

Holds a delegate that is executed when a monitored process produces output. */.

Protected variable

FString

 

Params

Holds the command line parameters. */.

Protected variable

FProcHandle

 

ProcessHandle

Holds the handle to the process. */.

Protected variable

void *

 

ReadPipe

Holds the read pipe. */.

Protected variable

int

 

ReturnCode

Holds the return code. */.

Protected variable

float

 

SleepInterval

Sleep interval to use.

Protected variable

FDateTime

 

StartTime

Holds the time at which the process started. */.

Protected variable

FRunnableThread...

 

Thread

Holds the monitoring thread object. */.

Protected variable

FString

 

URL

Holds the URL of the executable to launch. */.

Protected variable

FString

 

WorkingDir

Holds the URL of the working dir for the process. */.

Protected variable

void *

 

WritePipe

Holds the write pipe. */.

Constructors

Name Description

Public function

FMonitoredProcess

(
    const FString& InURL,
    const FString& InParams,
    bool InHidden,
    bool InCreatePipes
)

Creates a new monitored process.

Public function

FMonitoredProcess

(
    const FString& InURL,
    const FString& InParams,
    const FString& InWorkingDir,
    bool InHidden,
    bool InCreatePipes
)

Creates a new monitored process.

Destructors

Name Description

Public function Virtual

~FMonitoredProcess()

Destructor.

Functions

Name Description

Public function

void

 

Cancel

(
    bool InKillTree
)

Cancels the process.

Public function Const

FTimespan

 

GetDuration()

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

Public function Const

FProcHandle

 

GetProcessHandle()

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

Public function Const

int

 

GetReturnCode()

Returns the return code from the exited process

Public function Virtual

bool

 

Launch()

Launches the process.

Public function

FSimpleDeleg...

 

OnCanceled()

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

Public function

FOnMonitored...

 

OnCompleted()

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

Public function

FOnMonitored...

 

OnOutput()

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

Protected function

void

 

ProcessOutput

(
    const FString& Output
)

Processes the given output string.

Public function

void

 

SetSleepInterval

(
    float InSleepInterval
)

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

Protected function

void

 

TickInternal()

Public function

bool

 

Update()

Checks whether the process is still running.

Overridden from FRunnable

Name Description

Public function Virtual

void

 

Exit()

Exits the runnable object.

Public function Virtual

FSingleThrea...

 

GetSingleThreadInterface()

Gets single thread interface pointer used for ticking this runnable when multi-threading is disabled.

Public function Virtual

bool

 

Init()

Initializes the runnable object.

Public function Virtual

uint32

 

Run()

Runs the runnable object.

Public function Virtual

void

 

Stop()

Stops the runnable object.

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

Overridden from FSingleThreadRunnable

Name Description

Protected function Virtual

void

 

Tick()

FSingleThreadRunnable interface