FreeNOS
|
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... | |
Helper class to launch an external program.
Definition at line 35 of file ApplicationLauncher.h.
Result code.
Enumerator | |
---|---|
Success | |
InvalidArgument | |
NotFound | |
IOError |
Definition at line 42 of file ApplicationLauncher.h.
ApplicationLauncher::ApplicationLauncher | ( | const char * | path, |
const char ** | argv | ||
) |
Constructor.
path | Full path to the program to run |
argv | Array with arguments |
Definition at line 28 of file ApplicationLauncher.cpp.
ApplicationLauncher::Result ApplicationLauncher::exec | ( | ) |
Runs the external program.
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().
const int ApplicationLauncher::getExitCode | ( | ) | const |
Retrieve exit code of the program.
Definition at line 42 of file ApplicationLauncher.cpp.
References m_exitCode, and WEXITSTATUS.
const ProcessID ApplicationLauncher::getPid | ( | ) | const |
Retrieve Process Identifier of the program.
Definition at line 37 of file ApplicationLauncher.cpp.
References m_pid.
Referenced by POSIXApplication::runProgram(), and MpiProxy::startLocalProcess().
ApplicationLauncher::Result ApplicationLauncher::terminate | ( | ) | const |
Terminate the program.
Definition at line 89 of file ApplicationLauncher.cpp.
References InvalidArgument, IOError, kill(), m_pid, SIGTERM, and Success.
ApplicationLauncher::Result ApplicationLauncher::wait | ( | ) |
Wait for the program to terminate.
Definition at line 106 of file ApplicationLauncher.cpp.
References errno, ESRCH, InvalidArgument, IOError, m_exitCode, m_pid, NotFound, Success, and waitpid().
|
private |
Array with pointers to program arguments.
Definition at line 101 of file ApplicationLauncher.h.
Referenced by exec().
|
private |
Exit code after the program has terminated.
Definition at line 107 of file ApplicationLauncher.h.
Referenced by getExitCode(), and wait().
|
private |
Absolute path to the program to run.
Definition at line 98 of file ApplicationLauncher.h.
Referenced by exec().
|
private |
PID of the DatastoreServer.
Definition at line 104 of file ApplicationLauncher.h.
Referenced by exec(), getPid(), terminate(), and wait().