DaZeus  2.0
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
pluginmonitor.h
Go to the documentation of this file.
1 
6 #ifndef PLUGINMONITOR_H
7 #define PLUGINMONITOR_H
8 
9 #include <signal.h>
10 #include <string>
11 #include <vector>
12 
13 namespace dazeus {
14 
15 struct PluginState;
16 struct PluginConfig;
17 struct NetworkConfig;
18 struct SocketConfig;
19 
35 {
36  public:
37  PluginMonitor(SocketConfig *socket, std::string pluginDirectory,
38  const std::vector<PluginConfig*> &plugins,
39  const std::vector<NetworkConfig*> &networks);
41 
42  bool shouldRun() { return should_run_; }
43  void runOnce();
44  void sigchild() { should_run_ = 1; }
45 
46  private:
47  // explicitly disable copy constructor
49  void operator=(const PluginMonitor&);
50 
51  bool start_plugin(PluginState *state);
52  static pid_t fork_plugin(const std::string path, const std::vector<std::string> arguments, const std::string executable);
53  static void stop_plugin(PluginState *state, bool hard);
54  static void plugin_failed(PluginState *state, bool permanent = false);
55 
56  std::string pluginDirectory_;
57  SocketConfig *socket_;
58  std::vector<PluginState*> state_;
59  volatile sig_atomic_t should_run_;
60 };
61 
62 }
63 
64 #endif