Added utility for spawning/monitoring/killing processes, fixed reaping of child processes for all Connectors

This commit is contained in:
Thulinma 2011-10-07 02:06:41 +02:00
parent 9fe909d034
commit b4bafce129
2 changed files with 166 additions and 0 deletions

28
util/proc.h Normal file
View file

@ -0,0 +1,28 @@
/// \file proc.h
/// Contains generic function headers for managing processes.
#include <unistd.h>
#include <string>
#include <map>
/// Contains utility code, not directly related to streaming media
namespace Util{
/// Deals with spawning, monitoring and stopping child processes
class Procs{
private:
static std::map<pid_t, std::string> plist; ///< Holds active processes
static bool handler_set; ///< If true, the sigchld handler has been setup.
static void childsig_handler(int signum);
public:
static pid_t Start(std::string name, std::string cmd);
static void Stop(std::string name);
static void Stop(pid_t name);
static void StopAll();
static int Count();
static bool isActive(std::string name);
static bool isActive(pid_t name);
static pid_t getPid(std::string name);
static std::string getName(pid_t name);
};
};