47 #ifndef _MIRA_PROCESSSPAWNMANAGER_H_ 48 #define _MIRA_PROCESSSPAWNMANAGER_H_ 53 #include <boost/algorithm/string.hpp> 106 boost::optional<Process::Environment>
env;
128 const std::string& name =
"",
129 bool respawn=
false,
bool required=
false,
130 bool shutdownRecursively=
false,
131 boost::optional<Process::Environment> env = boost::optional<Process::Environment>(),
132 const std::string& cleanupCmd=
"")
138 info->respawn = respawn;
139 info->required = required;
142 if (shutdownRecursively)
149 info->pid =
toString(info->process.getPID());
151 info->shutdownRecursively = shutdownRecursively;
152 info->executable = executable;
155 info->cleanup_cmd = cleanupCmd;
159 boost::mutex::scoped_lock lock(
mMutex);
178 while(!boost::this_thread::interruption_requested()) {
181 boost::mutex::scoped_lock lock(
mMutex);
184 if(info->process.isRunning())
188 <<
"was terminated.";
193 if (info->shutdownRecursively)
199 info->pid =
toString(info->process.getPID());
200 }
else if(info->required) {
Macro for iterating over all elements in a container.
Different functions for searching files or directories.
static Process createProcess(const std::string &commandLine, CreationFlags flags, RedirectionFlags streamRedirection=none)
Spawns a new process and executes the given command line.
Definition: Process.h:221
boost::mutex mMutex
Definition: ProcessSpawnManager.h:114
Header including various log headers.
static Type & instance()
Returns a reference to the singleton instance.
Definition: Singleton.h:544
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
boost::filesystem::path Path
Typedef of a Path (shorter version for boost::filesystem::path)
Definition: Path.h:69
A thread monitor, which collects information about the resources of all running threads of the curren...
bool shutdownRecursively
Definition: ProcessSpawnManager.h:103
boost::thread mWatchdogThread
Definition: ProcessSpawnManager.h:113
~ProcessInfo()
Definition: ProcessSpawnManager.h:79
Implements manager that starts processes and keeps track of them in order to respawn them if required...
Definition: ProcessSpawnManager.h:73
#define MIRA_LOG(level)
Use this macro to log data.
Definition: LoggingCore.h:529
boost::function< void(const ProcessInfo &p)> RequiredProcessTerminatedFn
Definition: ProcessSpawnManager.h:116
std::string name
Definition: ProcessSpawnManager.h:97
boost::optional< Process::Environment > env
Definition: ProcessSpawnManager.h:106
static bool isDestroyed()
Returns true, if the singleton was already destroyed.
Definition: Singleton.h:552
Encapsulates a process, that was launched from the current process.
Definition: Process.h:96
std::string toString(const T &value, int precision=-1)
Converts any data type to string (the data type must support the stream << operator).
Definition: ToString.h:256
std::list< ProcessInfoPtr > mProcesses
Definition: ProcessSpawnManager.h:111
std::string getName() const
Definition: ProcessSpawnManager.h:88
Path executable
Definition: ProcessSpawnManager.h:104
sec_type seconds() const
Returns normalized number of seconds (0..59)
Definition: Time.h:280
std::vector< std::string > args
Definition: ProcessSpawnManager.h:105
bool required
Definition: ProcessSpawnManager.h:100
Definition: ProcessSpawnManager.h:77
RequiredProcessTerminatedFn mRequiredProcessTerminatedFn
Definition: ProcessSpawnManager.h:118
boost::shared_ptr< ProcessInfo > ProcessInfoPtr
Definition: ProcessSpawnManager.h:109
CreationFlags
Definition: Process.h:205
If true, shutdown will determine the complete progeny of the spawned process and eradicate it (top do...
Definition: Process.h:215
std::string cleanup_cmd
Definition: ProcessSpawnManager.h:107
void watchdog()
Definition: ProcessSpawnManager.h:173
Definition: LoggingCore.h:76
Functions for modifying file system paths.
Platform independent system calls.
std::string pid
Definition: ProcessSpawnManager.h:98
void startWatchdog(RequiredProcessTerminatedFn fn=RequiredProcessTerminatedFn())
Definition: ProcessSpawnManager.h:164
Process process
Definition: ProcessSpawnManager.h:95
void startProcess(const Path &executable, const std::vector< std::string > &args, const std::string &name="", bool respawn=false, bool required=false, bool shutdownRecursively=false, boost::optional< Process::Environment > env=boost::optional< Process::Environment >(), const std::string &cleanupCmd="")
Definition: ProcessSpawnManager.h:127
Will send the SIGINT signal to the child when the parent gets killed.
Definition: Process.h:209
bool respawn
Definition: ProcessSpawnManager.h:99
~ProcessSpawnManager()
Definition: ProcessSpawnManager.h:121
Definition: LoggingCore.h:77