Learn Environment
Public Slots | Signals | Public Member Functions | List of all members
ProcessRunner Class Reference

Manages the execution of an external process with a timeout. More...

#include <process_runner.hpp>

Inheritance diagram for ProcessRunner:
Inheritance graph
Collaboration diagram for ProcessRunner:
Collaboration graph

Public Slots

void forceStop ()
 Forces the stop of the running process. More...
 

Signals

void finished (int exitCode, QProcess::ExitStatus exitStatus)
 Signal emitted when the process finishes. More...
 
void outputReady (const QString &output)
 Signal emitted when the process produces output. More...
 
void errorReady (const QString &error)
 Signal emitted when the process produces an error. More...
 
void timeout ()
 Signal emitted when the process times out. More...
 

Public Member Functions

 ProcessRunner (const QString &program, const QStringList &arguments, int timeoutSeconds, QObject *parent=nullptr, QString processName="process")
 Constructs a ProcessRunner object. More...
 
void start ()
 Starts the execution of the process. More...
 

Detailed Description

Manages the execution of an external process with a timeout.

The ProcessRunner class is responsible for starting an external process, capturing its output and errors, and enforcing a timeout for its execution.

Constructor & Destructor Documentation

◆ ProcessRunner()

ProcessRunner::ProcessRunner ( const QString &  program,
const QStringList &  arguments,
int  timeoutSeconds,
QObject parent = nullptr,
QString  processName = "process" 
)

Constructs a ProcessRunner object.

Parameters
programThe program to be executed.
argumentsThe arguments to be passed to the program.
timeoutSecondsThe timeout for the process execution in seconds.
parentPointer to the parent QObject.
processNameThe name of the process (for logging purposes).

Member Function Documentation

◆ errorReady

void ProcessRunner::errorReady ( const QString &  error)
signal

Signal emitted when the process produces an error.

Parameters
errorThe error produced by the process.

◆ finished

void ProcessRunner::finished ( int  exitCode,
QProcess::ExitStatus  exitStatus 
)
signal

Signal emitted when the process finishes.

Parameters
exitCodeThe exit code of the process.
exitStatusThe exit status of the process.
Here is the caller graph for this function:

◆ forceStop

void ProcessRunner::forceStop ( )
slot

Forces the stop of the running process.

Here is the caller graph for this function:

◆ outputReady

void ProcessRunner::outputReady ( const QString &  output)
signal

Signal emitted when the process produces output.

Parameters
outputThe output produced by the process.

◆ start()

void ProcessRunner::start ( )

Starts the execution of the process.

Here is the caller graph for this function:

◆ timeout

void ProcessRunner::timeout ( )
signal

Signal emitted when the process times out.

Here is the caller graph for this function:

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