wibble
1.1
Main Page
Namespaces
Classes
Files
File List
File Members
wibble
sys
exec.h
Go to the documentation of this file.
1
#ifndef WIBBLE_SYS_EXEC_H
2
#define WIBBLE_SYS_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
24
#include <
wibble/sys/childprocess.h
>
25
26
namespace
wibble {
27
namespace
sys {
28
33
class
Exec
:
public
ChildProcess
34
{
35
protected
:
40
virtual
int
main
();
41
virtual
void
spawnChild
();
42
43
public
:
44
virtual
~Exec
() {}
45
52
std::string
pathname
;
53
59
std::vector<std::string>
args
;
60
64
std::vector<std::string>
env
;
65
70
bool
envFromParent
;
71
78
bool
searchInPath
;
79
81
Exec
(
const
std::string&
pathname
)
82
: pathname(pathname),
envFromParent
(true),
searchInPath
(false)
83
{
84
args
.push_back(pathname);
85
}
86
88
void
importEnv
();
89
91
void
exec
();
92
};
93
97
class
ShellCommand
:
public
Exec
98
{
99
public
:
100
ShellCommand
(
const
std::string& cmd) :
101
#ifdef POSIX
102
Exec
(
"/bin/sh"
)
103
#elif defined _WIN32
104
Exec
(
"bash"
)
// let's hope for the best...
105
#endif
106
{
107
args
.push_back(
"-c"
);
108
args
.push_back(cmd);
109
searchInPath
=
false
;
110
envFromParent
=
true
;
111
}
112
};
113
114
}
115
}
116
117
// vim:set ts=4 sw=4:
118
#endif
Generated on Wed Oct 23 2013 17:14:25 for wibble by
1.8.4