Deals with spawning, monitoring and stopping child processes.
More...
#include <procs.h>
|
static int | Count () |
| Returns the number of active child processes. More...
|
|
static int | Count () |
|
static std::string | getOutputOf (char *const *argv) |
| Runs the given command and returns the stdout output as a string. More...
|
|
static std::string | getOutputOf (char *const *argv) |
|
static std::string | getOutputOf (std::deque< std::string > &argDeq) |
|
static std::string | getOutputOf (std::deque< std::string > &argDeq) |
|
static bool | isActive (pid_t name) |
| Returns true if a process with this PID is currently active. More...
|
|
static bool | isActive (pid_t name) |
|
static bool | isRunning (pid_t pid) |
|
static bool | isRunning (pid_t pid) |
| sends sig 0 to process (pid). returns true if process is running More...
|
|
static void | Murder (pid_t name) |
|
static void | Murder (pid_t name) |
| Stops the process with this pid, if running. More...
|
|
static pid_t | StartPiped (char *const *argv, int *fdin, int *fdout, int *fderr) |
|
static pid_t | StartPiped (char *const *argv, int *fdin, int *fdout, int *fderr) |
| Starts a new process with given fds if the name is not already active. More...
|
|
static pid_t | StartPiped (std::deque< std::string > &argDeq, int *fdin, int *fdout, int *fderr) |
|
static pid_t | StartPiped (std::deque< std::string > &argDeq, int *fdin, int *fdout, int *fderr) |
|
static void | Stop (pid_t name) |
|
static void | Stop (pid_t name) |
| Stops the process with this pid, if running. More...
|
|
static void | StopAll () |
| (Attempts to) stop all running child processes. More...
|
|
static void | StopAll () |
|
|
static void | childsig_handler (int signum) |
| Used internally to capture child signals and update plist. More...
|
|
static void | childsig_handler (int signum) |
|
static char *const * | dequeToArgv (std::deque< std::string > &argDeq) |
| This function prepares a deque for getOutputOf and automatically inserts a NULL at the end of the char* const*. More...
|
|
static char *const * | dequeToArgv (std::deque< std::string > &argDeq) |
|
static void | exit_handler () |
|
static void | exit_handler () |
| Called at exit of any program that used a Start* function. More...
|
|
static void | runCmd (std::string &cmd) |
|
static void | runCmd (std::string &cmd) |
|
static void | setHandler () |
| Sets up exit and childsig handlers. More...
|
|
static void | setHandler () |
|
Deals with spawning, monitoring and stopping child processes.
void Util::Procs::childsig_handler |
( |
int |
signum | ) |
|
|
staticprivate |
Used internally to capture child signals and update plist.
static void Util::Procs::childsig_handler |
( |
int |
signum | ) |
|
|
staticprivate |
int Util::Procs::Count |
( |
| ) |
|
|
static |
Returns the number of active child processes.
static int Util::Procs::Count |
( |
| ) |
|
|
static |
char *const * Util::Procs::dequeToArgv |
( |
std::deque< std::string > & |
argDeq | ) |
|
|
staticprivate |
This function prepares a deque for getOutputOf and automatically inserts a NULL at the end of the char* const*.
static char* const* Util::Procs::dequeToArgv |
( |
std::deque< std::string > & |
argDeq | ) |
|
|
staticprivate |
static void Util::Procs::exit_handler |
( |
| ) |
|
|
staticprivate |
void Util::Procs::exit_handler |
( |
| ) |
|
|
staticprivate |
Called at exit of any program that used a Start* function.
Waits up to 1 second, then sends SIGINT signal to all managed processes. After that waits up to 5 seconds for children to exit, then sends SIGKILL to all remaining children. Waits one more second for cleanup to finish, then exits.
static std::string Util::Procs::getOutputOf |
( |
char *const * |
argv | ) |
|
|
static |
std::string Util::Procs::getOutputOf |
( |
char *const * |
argv | ) |
|
|
static |
Runs the given command and returns the stdout output as a string.
static std::string Util::Procs::getOutputOf |
( |
std::deque< std::string > & |
argDeq | ) |
|
|
static |
std::string Util::Procs::getOutputOf |
( |
std::deque< std::string > & |
argDeq | ) |
|
|
static |
bool Util::Procs::isActive |
( |
pid_t |
name | ) |
|
|
static |
Returns true if a process with this PID is currently active.
static bool Util::Procs::isActive |
( |
pid_t |
name | ) |
|
|
static |
static bool Util::Procs::isRunning |
( |
pid_t |
pid | ) |
|
|
static |
bool Util::Procs::isRunning |
( |
pid_t |
pid | ) |
|
|
static |
sends sig 0 to process (pid). returns true if process is running
void Util::Procs::Murder |
( |
pid_t |
name | ) |
|
|
static |
Stops the process with this pid, if running.
- name The PID of the process to murder.
static void Util::Procs::Murder |
( |
pid_t |
name | ) |
|
|
static |
static void Util::Procs::runCmd |
( |
std::string & |
cmd | ) |
|
|
staticprivate |
static void Util::Procs::runCmd |
( |
std::string & |
cmd | ) |
|
|
staticprivate |
void Util::Procs::setHandler |
( |
| ) |
|
|
staticprivate |
Sets up exit and childsig handlers.
Called by every Start* function.
static void Util::Procs::setHandler |
( |
| ) |
|
|
staticprivate |
static pid_t Util::Procs::StartPiped |
( |
char *const * |
argv, |
|
|
int * |
fdin, |
|
|
int * |
fdout, |
|
|
int * |
fderr |
|
) |
| |
|
static |
pid_t Util::Procs::StartPiped |
( |
char *const * |
argv, |
|
|
int * |
fdin, |
|
|
int * |
fdout, |
|
|
int * |
fderr |
|
) |
| |
|
static |
Starts a new process with given fds if the name is not already active.
- Returns
- 0 if process was not started, process PID otherwise.
- argv Command for this process.
- fdin Standard input file descriptor. If null, /dev/null is assumed. Otherwise, if arg contains -1, a new fd is automatically allocated and written into this arg. Then the arg will be used as fd.
- fdout Same as fdin, but for stdout.
- fdout Same as fdin, but for stderr.
pid_t Util::Procs::StartPiped |
( |
std::deque< std::string > & |
argDeq, |
|
|
int * |
fdin, |
|
|
int * |
fdout, |
|
|
int * |
fderr |
|
) |
| |
|
static |
static pid_t Util::Procs::StartPiped |
( |
std::deque< std::string > & |
argDeq, |
|
|
int * |
fdin, |
|
|
int * |
fdout, |
|
|
int * |
fderr |
|
) |
| |
|
static |
static void Util::Procs::Stop |
( |
pid_t |
name | ) |
|
|
static |
void Util::Procs::Stop |
( |
pid_t |
name | ) |
|
|
static |
Stops the process with this pid, if running.
- name The PID of the process to stop.
void Util::Procs::StopAll |
( |
| ) |
|
|
static |
(Attempts to) stop all running child processes.
static void Util::Procs::StopAll |
( |
| ) |
|
|
static |
static bool Util::Procs::handler_set = false |
|
staticprivate |
If true, the sigchld handler has been setup.
static std::set< pid_t > Util::Procs::plist |
|
staticprivate |
The documentation for this class was generated from the following files: