Process Class Reference

#include <Pt/System/Process.h>

Starts another program as a child process. More...

Inherits NonCopyable.

Public Types

enum  State {
  Ready = 0 ,
  Running = 1 ,
  Finished = 2 ,
  Failed = 3
}
 State of the process. More...

Public Member Functions

 Process (const ProcessInfo &procInfo)
 Constructs with a process parameters.
 ~Process ()
 Destructor.
const ProcessInfoprocInfo () const
 Returns the process parameters.
State state () const
 Returns the current state.
void start ()
 Start/Create the Process.
void kill ()
 Kills the Process.
int wait ()
 Waits until the Process ends.
bool tryWait (int &status)
 Returns true if the process has finished.
IODevicestdInput ()
 Returns an I/O device to stdin.
IODevicestdOutput ()
 Returns an I/O device to stdout.
IODevicestdError ()
 Returns an I/O device to stderr.

Detailed Description

Construct with a ProcessInfo that names the command, arguments, and how stdin, stdout, and stderr are handled. start() runs the program. wait() joins it and returns the exit status. tryWait() reports whether it has finished. kill() terminates it. stdInput(), stdOutput(), and stdError() return the redirected IODevice endpoints when redirection was requested.

Exceptions
SystemErrorif start(), kill(), or wait() fails.
ProcessFailedif wait() finds a non-normal termination.

Member Enumeration Documentation

◆ State

enum State
Enumerator
Ready 

Ready to run.

Running 

Currently running.

Finished 

Finished to run.

Failed 

Execution has failed.

Member Function Documentation

◆ start()

void start ( )
Exceptions
SystemError

◆ kill()

void kill ( )
Exceptions
SystemError

◆ wait()

int wait ( )

◆ tryWait()

bool tryWait ( int & status)

Sets status to the exit status when the process has finished.