libcamgm
ExternalProgram.hpp
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #ifndef CA_MGM_EXTERNALPROGRAM_H
14 #define CA_MGM_EXTERNALPROGRAM_H
15 
16 #include <map>
17 #include <string>
18 #include <vector>
19 
21 #include <ca-mgm/PathName.hpp>
22 
23 namespace ca_mgm {
24 
57  {
58 
59  public:
60 
61  typedef std::vector<std::string> Arguments;
62 
72  };
73 
74 
78  typedef std::map<std::string,std::string> Environment;
79 
88  ExternalProgram (std::string commandline,
89  Stderr_Disposition stderr_disp = Normal_Stderr,
90  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
91  const path::PathName& root = "");
92 
100  ExternalProgram();
101 
102  ExternalProgram (const Arguments &argv,
103  Stderr_Disposition stderr_disp = Normal_Stderr,
104  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
105  const path::PathName& root = "");
106 
107  ExternalProgram (const Arguments &argv, const Environment & environment,
108  Stderr_Disposition stderr_disp = Normal_Stderr,
109  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
110  const path::PathName& root = "");
111 
112  ExternalProgram (const char *const *argv,
113  Stderr_Disposition stderr_disp = Normal_Stderr,
114  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
115  const path::PathName& root = "");
116 
117  ExternalProgram (const char *const *argv, const Environment & environment,
118  Stderr_Disposition stderr_disp = Normal_Stderr,
119  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
120  const path::PathName& root = "");
121 
122  ExternalProgram (const char *binpath, const char *const *argv_1,
123  bool use_pty = false);
124 
125 
126  ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
127  bool use_pty = false);
128 
129 
131 
132  int close();
133 
137  bool kill();
138 
142  bool running();
143 
147  pid_t getpid() { return pid; }
148 
150  const std::string & command() const
151  { return _command; }
152 
162  const std::string & execError() const
163  { return _execError; }
164 
168  static void renumber_fd (int origfd, int newfd);
169 
170  protected:
171  int checkStatus( int );
172 
173  private:
174 
179  bool use_pty;
180 
181  pid_t pid;
184  std::string _command;
186  std::string _execError;
187 
188  void start_program (const char *const *argv, const Environment & environment,
189  Stderr_Disposition stderr_disp = Normal_Stderr,
190  int stderr_fd = -1, bool default_locale = false,
191  const char* root = NULL);
192 
193  };
194 
195 } // namespace ca_mgm
196 
197 #endif // CA_MGM_EXTERNALPROGRAM_H
const std::string & execError() const
Definition: ExternalProgram.hpp:162
Definition: ExternalProgram.hpp:71
std::vector< std::string > Arguments
Definition: ExternalProgram.hpp:61
Definition: ExternalProgram.hpp:70
PathName manipulation class.
Definition: PathName.hpp:65
bool use_pty
Definition: ExternalProgram.hpp:179
Stderr_Disposition
Definition: ExternalProgram.hpp:67
pid_t getpid()
Definition: ExternalProgram.hpp:147
LiMaL path name manipulation utilities.
std::string _execError
Definition: ExternalProgram.hpp:186
const std::string & command() const
Definition: ExternalProgram.hpp:150
Definition: ExternalProgram.hpp:68
int _exitStatus
Definition: ExternalProgram.hpp:182
std::string _command
Definition: ExternalProgram.hpp:184
pid_t pid
Definition: ExternalProgram.hpp:181
Definition: ExternalProgram.hpp:69
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Definition: ExternalProgram.hpp:56
void start_program(const char *const *argv, const Environment &environment, Stderr_Disposition stderr_disp=Normal_Stderr, int stderr_fd=-1, bool default_locale=false, const char *root=NULL)
Bidirectional stream to external data.
Definition: ExternalDataSource.hpp:27
std::map< std::string, std::string > Environment
Definition: ExternalProgram.hpp:78
static void renumber_fd(int origfd, int newfd)
Definition: ByteBuffer.hpp:37