FreeNOS
Public Types | Public Member Functions | Private Attributes
ApplicationLauncher Class Reference

Helper class to launch an external program. More...

#include <ApplicationLauncher.h>

Public Types

enum  Result { Success, InvalidArgument, NotFound, IOError }
 Result code. More...
 

Public Member Functions

 ApplicationLauncher (const char *path, const char **argv)
 Constructor. More...
 
const ProcessID getPid () const
 Retrieve Process Identifier of the program. More...
 
const int getExitCode () const
 Retrieve exit code of the program. More...
 
Result exec ()
 Runs the external program. More...
 
Result terminate () const
 Terminate the program. More...
 
Result wait ()
 Wait for the program to terminate. More...
 

Private Attributes

const String m_path
 Absolute path to the program to run. More...
 
const char ** m_argv
 Array with pointers to program arguments. More...
 
ProcessID m_pid
 PID of the DatastoreServer. More...
 
int m_exitCode
 Exit code after the program has terminated. More...
 

Detailed Description

Helper class to launch an external program.

Definition at line 35 of file ApplicationLauncher.h.

Member Enumeration Documentation

◆ Result

Result code.

Enumerator
Success 
InvalidArgument 
NotFound 
IOError 

Definition at line 42 of file ApplicationLauncher.h.

Constructor & Destructor Documentation

◆ ApplicationLauncher()

ApplicationLauncher::ApplicationLauncher ( const char *  path,
const char **  argv 
)

Constructor.

Parameters
pathFull path to the program to run
argvArray with arguments

Definition at line 28 of file ApplicationLauncher.cpp.

Member Function Documentation

◆ exec()

ApplicationLauncher::Result ApplicationLauncher::exec ( )

Runs the external program.

Returns
Result code

Definition at line 47 of file ApplicationLauncher.cpp.

References DEBUG, errno, ERROR, exit(), forkexec(), IOError, m_argv, m_path, m_pid, NotFound, NULL, stat(), strerror(), and Success.

Referenced by POSIXApplication::runProgram(), and MpiProxy::startLocalProcess().

◆ getExitCode()

const int ApplicationLauncher::getExitCode ( ) const

Retrieve exit code of the program.

Returns
Exit code

Definition at line 42 of file ApplicationLauncher.cpp.

References m_exitCode, and WEXITSTATUS.

◆ getPid()

const ProcessID ApplicationLauncher::getPid ( ) const

Retrieve Process Identifier of the program.

Returns
ProcessID

Definition at line 37 of file ApplicationLauncher.cpp.

References m_pid.

Referenced by POSIXApplication::runProgram(), and MpiProxy::startLocalProcess().

◆ terminate()

ApplicationLauncher::Result ApplicationLauncher::terminate ( ) const

Terminate the program.

Returns
Result code

Definition at line 89 of file ApplicationLauncher.cpp.

References InvalidArgument, IOError, kill(), m_pid, SIGTERM, and Success.

◆ wait()

ApplicationLauncher::Result ApplicationLauncher::wait ( )

Wait for the program to terminate.

Returns
Result code

Definition at line 106 of file ApplicationLauncher.cpp.

References errno, ESRCH, InvalidArgument, IOError, m_exitCode, m_pid, NotFound, Success, and waitpid().

Field Documentation

◆ m_argv

const char** ApplicationLauncher::m_argv
private

Array with pointers to program arguments.

Definition at line 101 of file ApplicationLauncher.h.

Referenced by exec().

◆ m_exitCode

int ApplicationLauncher::m_exitCode
private

Exit code after the program has terminated.

Definition at line 107 of file ApplicationLauncher.h.

Referenced by getExitCode(), and wait().

◆ m_path

const String ApplicationLauncher::m_path
private

Absolute path to the program to run.

Definition at line 98 of file ApplicationLauncher.h.

Referenced by exec().

◆ m_pid

ProcessID ApplicationLauncher::m_pid
private

PID of the DatastoreServer.

Definition at line 104 of file ApplicationLauncher.h.

Referenced by exec(), getPid(), terminate(), and wait().


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