Public Types | Public Member Functions | Static Public Member Functions

base::Process Class Reference

Creating processes and executing programs. More...

#include <libppbase/base/Process.h>

List of all members.

Public Types

enum  { execCaptureStdIo = 1, execMergeStdErrAndStdOut = 2, execInheritHandles = 4 }
 

execution flags

More...
typedef pid_t pid_type
 process id type

Public Member Functions

 Process ()
 Creates an empty object.
 ~Process ()
 Destructor.
void execute (int flags=0)
 Executes the program.
bool exitedBySignal () const
 Checks if the program exited because of a signal.
int getExitCode () const
 Gets the program exit code.
int getExitSignal () const
 Gets the signal number that caused the program to exit.
FilegetStdErr ()
 Gets the standard error of the currently executing program.
FilegetStdIn ()
 Gets the standard input of the currently executing program.
FilegetStdOut ()
 Gets the standard output of the currently executing program.
void setArguments (const std::vector< String > &arguments)
 Sets the command line arguments.
void setArguments (const String &arguments)
 Sets the command line arguments.
void setProgram (const String &program)
 Sets the program to execute.
void terminate (int exitcode)
 Terminates the running program by sending a terminate request.
bool wait (unsigned timeout=0)
 Waits for the program to exit.

Static Public Member Functions

static int getCurrentProcessId ()
 Gets the own process id.

Detailed Description

Creating processes and executing programs.

Author:
Christoph Schwarz
Version:
$Id: Process.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Enumeration Documentation

anonymous enum

execution flags

Enumerator:
execCaptureStdIo 

flag: capture standard input and output

execMergeStdErrAndStdOut 

flag: merge stderr and stdout

execInheritHandles 

flag: inherit handles (Windows only)


Member Function Documentation

void base::Process::execute ( int  flags = 0  ) 

Executes the program.

Parameters:
flags execute flags: Process::exec*
bool base::Process::exitedBySignal (  )  const

Checks if the program exited because of a signal.

Returns:
true if the program exited because of a signal, false if not
static int base::Process::getCurrentProcessId (  )  [static]

Gets the own process id.

Returns:
own process id
int base::Process::getExitCode (  )  const

Gets the program exit code.

Returns:
the program exit code
int base::Process::getExitSignal (  )  const

Gets the signal number that caused the program to exit.

Returns:
the signal number
File* base::Process::getStdErr (  ) 

Gets the standard error of the currently executing program.

Returns:
the standard error stream
File* base::Process::getStdIn (  ) 

Gets the standard input of the currently executing program.

Returns:
the standard input stream
File* base::Process::getStdOut (  ) 

Gets the standard output of the currently executing program.

Returns:
the standard output stream
void base::Process::setArguments ( const std::vector< String > &  arguments  ) 

Sets the command line arguments.

Parameters:
arguments the command line arguments
void base::Process::setArguments ( const String arguments  ) 

Sets the command line arguments.

Parameters:
arguments the command line arguments
void base::Process::setProgram ( const String program  ) 

Sets the program to execute.

Parameters:
program the program name
void base::Process::terminate ( int  exitcode  ) 

Terminates the running program by sending a terminate request.

Termination of a process is platform-dependent. On Windows, a terminate request is sent through the TerminateProcess system call. On UNIX the process is sent a KILL signal. Regardless of the plaform, the caller must call wait() after calling terminate() to wait for the process to terminate and to free all associated resources.

Parameters:
exitcode the program exit code to set (required for Windows only, Linux ignores this parameter)
bool base::Process::wait ( unsigned  timeout = 0  ) 

Waits for the program to exit.

Parameters:
timeout timeout in seconds, 0 means to wait infinite
Returns:
true if the program exited, false if a timeout occurred

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