wibble  0.1.28
exec.h
Go to the documentation of this file.
1 #ifndef EXEC_H
2 #define EXEC_H
3 
4 /*
5  * OO wrapper for execve
6  *
7  * Copyright (C) 2003 Enrico Zini <enrico@debian.org>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
25 
26 namespace wibble {
27 namespace sys {
28 
33 class Exec : public ChildProcess
34 {
35 protected:
40  virtual int main();
41 
42 public:
43  virtual ~Exec() {}
44 
51  std::string pathname;
52 
58  std::vector<std::string> args;
59 
63  std::vector<std::string> env;
64 
70 
78 
80  Exec(const std::string& pathname)
81  : pathname(pathname), envFromParent(true), searchInPath(false)
82  {
83  args.push_back(pathname);
84  }
85 
87  void importEnv();
88 
90  void exec();
91 };
92 
96 class ShellCommand : public Exec
97 {
98 public:
99  ShellCommand(const std::string& cmd) : Exec("/bin/sh")
100  {
101  args.push_back("-c");
102  args.push_back(cmd);
103  searchInPath = false;
104  envFromParent = true;
105  }
106 };
107 
108 }
109 }
110 
111 // vim:set ts=4 sw=4:
112 #endif