#include <ProcessManager.h>
|
static void | startSignalHandler () |
| Starts the signal handler thread. More...
|
|
static void | startSignalHandler (BaseLib::ThreadManager &threadManager) |
| Starts the signal handler thread. More...
|
|
static void | stopSignalHandler () |
|
static void | stopSignalHandler (BaseLib::ThreadManager &threadManager) |
|
static int32_t | registerCallbackHandler (std::function< void(pid_t pid, int exitCode, int signal, bool coreDumped)> callbackHandler) |
|
static void | unregisterCallbackHandler (int32_t id) |
|
static std::vector< std::string > | splitArguments (const std::string &arguments) |
|
static std::string | findProgramInPath (const std::string &relativePath) |
|
static pid_t | system (const std::string &path, const std::vector< std::string > &arguments, int maxFd) |
| Starts a program and returns the process id. More...
|
|
static pid_t | systemp (const std::string &path, const std::vector< std::string > &arguments, int maxFd, int &stdIn, int &stdOut, int &stdErr) |
| Starts a program with redirected pipe and returns the process id. More...
|
|
static int32_t | exec (const std::string &command, int maxFd, std::string &output) |
| Starts a program and returns the output. More...
|
|
static bool | exec (const std::string &command, int maxFd) |
| Starts a program and detaches it, so it continues to run when the parent process finishes. More...
|
|
static FILE * | popen2 (const std::string &command, const std::string &type, int maxFd, pid_t &pid) |
| Custom implementation of popen that returns the pid. More...
|
|
§ ProcessManager()
BaseLib::ProcessManager::ProcessManager |
( |
| ) |
|
|
delete |
§ exec() [1/2]
int32_t BaseLib::ProcessManager::exec |
( |
const std::string & |
command, |
|
|
int |
maxFd, |
|
|
std::string & |
output |
|
) |
| |
|
static |
Starts a program and returns the output.
- Parameters
-
| command | The command to execute. |
| maxFd | The maximum number of file descriptors. |
[out] | output | The program output. |
- Returns
- Returns the programs exit code.
§ exec() [2/2]
bool BaseLib::ProcessManager::exec |
( |
const std::string & |
command, |
|
|
int |
maxFd |
|
) |
| |
|
static |
Starts a program and detaches it, so it continues to run when the parent process finishes.
- Parameters
-
command | The command to execute. |
maxFd | The maximum number of file descriptors. |
- Returns
- Returns true when the process started successfully.
§ findProgramInPath()
std::string BaseLib::ProcessManager::findProgramInPath |
( |
const std::string & |
relativePath | ) |
|
|
static |
§ popen2()
FILE * BaseLib::ProcessManager::popen2 |
( |
const std::string & |
command, |
|
|
const std::string & |
type, |
|
|
int |
maxFd, |
|
|
pid_t & |
pid |
|
) |
| |
|
static |
Custom implementation of popen that returns the pid.
- Parameters
-
- Returns
§ registerCallbackHandler()
int32_t BaseLib::ProcessManager::registerCallbackHandler |
( |
std::function< void(pid_t pid, int exitCode, int signal, bool coreDumped)> |
callbackHandler | ) |
|
|
static |
§ splitArguments()
std::vector< std::string > BaseLib::ProcessManager::splitArguments |
( |
const std::string & |
arguments | ) |
|
|
static |
§ startSignalHandler() [1/2]
void BaseLib::ProcessManager::startSignalHandler |
( |
| ) |
|
|
static |
Starts the signal handler thread.
Must be called from main thread. You need to call stopSignalHandler() before exiting the program. When using ThreadManager, pass it to this method.
§ startSignalHandler() [2/2]
Starts the signal handler thread.
Must be called from main thread. You need to call stopSignalHandler() before exiting the program. When using ThreadManager, pass it to this method.
§ stopSignalHandler() [1/2]
void BaseLib::ProcessManager::stopSignalHandler |
( |
| ) |
|
|
static |
§ stopSignalHandler() [2/2]
§ system()
pid_t BaseLib::ProcessManager::system |
( |
const std::string & |
path, |
|
|
const std::vector< std::string > & |
arguments, |
|
|
int |
maxFd |
|
) |
| |
|
static |
Starts a program and returns the process id.
- Parameters
-
path | The program to start. If path is relative, PATH is searched. |
arguments | The arguments to pass. |
maxFd | The maximum possible file descriptor. Needed to close all open file descriptors in the child process. |
- Exceptions
-
- Returns
- Returns the PID on success and "-1" on error.
§ systemp()
pid_t BaseLib::ProcessManager::systemp |
( |
const std::string & |
path, |
|
|
const std::vector< std::string > & |
arguments, |
|
|
int |
maxFd, |
|
|
int & |
stdIn, |
|
|
int & |
stdOut, |
|
|
int & |
stdErr |
|
) |
| |
|
static |
Starts a program with redirected pipe and returns the process id.
- Parameters
-
| path | The program to start. If path is relative, PATH is searched. |
| arguments | The arguments to pass. |
[out] | stdIn | Will be filled with the input file descriptor. Close it when the process finishes. |
[out] | stdOut | Will be filled with the output file descriptor. Close it when the process finishes. |
[out] | stdErr | Will be filled with the error file descriptor. Close it when the process finishes. |
- Exceptions
-
- Returns
- Returns the PID on success and "-1" on error.
§ unregisterCallbackHandler()
void BaseLib::ProcessManager::unregisterCallbackHandler |
( |
int32_t |
id | ) |
|
|
static |
The documentation for this class was generated from the following files: