18 #ifndef SHEVEK_PROCESS_HH
19 #define SHEVEK_PROCESS_HH
32 static Glib::RefPtr <process>
create (std::string
const &command,
33 std::list <std::string> &argv,
34 bool pipe_stdin =
true,
35 bool pipe_stdout =
true,
36 bool pipe_stderr =
true);
38 static Glib::RefPtr <process>
create (std::string
const &command,
39 std::list <std::string> &argv,
40 std::list <std::string>
const &envp,
41 bool pipe_stdin =
true,
42 bool pipe_stdout =
true,
43 bool pipe_stderr =
true);
47 static Glib::RefPtr <process>
shell (std::string
const &command,
48 bool pipe_stdin =
true,
49 bool pipe_stdout =
true,
50 bool pipe_stderr =
true,
51 std::string
const &sh =
"/bin/sh")
53 std::list <std::string>
args;
55 args.push_back (
"-c");
56 args.push_back (command);
57 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
60 Glib::RefPtr <shevek::fd>
in ();
62 Glib::RefPtr <shevek::fd>
out ();
64 Glib::RefPtr <shevek::fd>
err ();
73 static std::string
run (std::string
const &command, std::string
const &sh);
75 static Glib::RefPtr <process>
create (std::string
const &command,
76 bool pipe_stdin =
true,
77 bool pipe_stdout =
true,
78 bool pipe_stderr =
true)
80 std::list <std::string>
args;
81 args.push_back (command);
82 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
85 static Glib::RefPtr <process>
create (std::string
const &command,
86 std::string
const &a1,
87 bool pipe_stdin =
true,
88 bool pipe_stdout =
true,
89 bool pipe_stderr =
true)
91 std::list <std::string>
args;
92 args.push_back (command);
94 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
97 static Glib::RefPtr <process>
create (std::string
const &command,
98 std::string
const &a1,
99 std::string
const &a2,
100 bool pipe_stdin =
true,
101 bool pipe_stdout =
true,
102 bool pipe_stderr =
true)
104 std::list <std::string>
args;
105 args.push_back (command);
108 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
111 static Glib::RefPtr <process>
create (std::string
const &command,
112 std::string
const &a1,
113 std::string
const &a2,
114 std::string
const &a3,
115 bool pipe_stdin =
true,
116 bool pipe_stdout =
true,
117 bool pipe_stderr =
true)
119 std::list <std::string>
args;
120 args.push_back (command);
124 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
127 static Glib::RefPtr <process>
create (std::string
const &command,
128 std::string
const &a1,
129 std::string
const &a2,
130 std::string
const &a3,
131 std::string
const &a4,
132 bool pipe_stdin =
true,
133 bool pipe_stdout =
true,
134 bool pipe_stderr =
true)
136 std::list <std::string>
args;
137 args.push_back (command);
142 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
145 static Glib::RefPtr <process>
create (std::string
const &command,
146 std::string
const &a1,
147 std::string
const &a2,
148 std::string
const &a3,
149 std::string
const &a4,
150 std::string
const &a5,
151 bool pipe_stdin =
true,
152 bool pipe_stdout =
true,
153 bool pipe_stderr =
true)
155 std::list <std::string>
args;
156 args.push_back (command);
162 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
165 static Glib::RefPtr <process>
create (std::string
const &command,
166 std::string
const &a1,
167 std::string
const &a2,
168 std::string
const &a3,
169 std::string
const &a4,
170 std::string
const &a5,
171 std::string
const &a6,
172 bool pipe_stdin =
true,
173 bool pipe_stdout =
true,
174 bool pipe_stderr =
true)
176 std::list <std::string>
args;
177 args.push_back (command);
184 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
187 static Glib::RefPtr <process>
create (std::string
const &command,
188 std::string
const &a1,
189 std::string
const &a2,
190 std::string
const &a3,
191 std::string
const &a4,
192 std::string
const &a5,
193 std::string
const &a6,
194 std::string
const &a7,
195 bool pipe_stdin =
true,
196 bool pipe_stdout =
true,
197 bool pipe_stderr =
true)
199 std::list <std::string>
args;
200 args.push_back (command);
208 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
211 static Glib::RefPtr <process>
create (std::string
const &command,
212 std::string
const &a1,
213 std::string
const &a2,
214 std::string
const &a3,
215 std::string
const &a4,
216 std::string
const &a5,
217 std::string
const &a6,
218 std::string
const &a7,
219 std::string
const &a8,
220 bool pipe_stdin =
true,
221 bool pipe_stdout =
true,
222 bool pipe_stderr =
true)
224 std::list <std::string>
args;
225 args.push_back (command);
234 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
237 static Glib::RefPtr <process>
create (std::string
const &command,
238 std::string
const &a1,
239 std::string
const &a2,
240 std::string
const &a3,
241 std::string
const &a4,
242 std::string
const &a5,
243 std::string
const &a6,
244 std::string
const &a7,
245 std::string
const &a8,
246 std::string
const &a9,
247 bool pipe_stdin =
true,
248 bool pipe_stdout =
true,
249 bool pipe_stderr =
true)
251 std::list <std::string>
args;
252 args.push_back (command);
262 return create (command, args, pipe_stdin, pipe_stdout, pipe_stderr);
265 Glib::RefPtr <shevek::fd> m_in, m_out, m_err;
267 process (std::string
const &command,
char **argv,
char **envp,
bool pipe_stdin,
bool pipe_stdout,
bool pipe_stderr);
268 static char **make_pointers (std::list <std::string>
const &source);
269 static void clean (
char **pointers);
270 static char *dup (
char const *str);