13#ifndef ZYPP_EXTERNALPROGRAM_H
14#define ZYPP_EXTERNALPROGRAM_H
22#include <zypp-core/Globals.h>
23#include <zypp-core/base/ExternalDataSource.h>
24#include <zypp-core/Pathname.h>
27 class AbstractSpawnEngine;
68 typedef std::vector<std::string>
Arguments;
84 typedef std::map<std::string,std::string>
Environment;
96 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
97 const Pathname& root =
"");
125 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
126 const Pathname& root =
"");
130 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
131 const Pathname& root =
"");
135 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
136 const Pathname& root =
"");
140 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
141 const Pathname& root =
"");
144 bool use_pty =
false);
148 bool use_pty =
false);
164 bool kill(
int sig );
177 const std::string &
command()
const;
215 std::ostream &
operator>>( std::ostream & out_r );
218 std::unique_ptr<zyppng::AbstractSpawnEngine>
_backend;
224 int stderr_fd = -1,
bool default_locale =
false,
225 const char* root = NULL,
bool switch_pgid =
false,
bool die_with_parent =
false,
bool usePty =
false );
230 namespace externalprogram
253 class ExternalProgramWithStderr :
private externalprogram::EarlyPipe,
public ExternalProgram
279 bool stderrGetUpTo( std::string & retval_r,
const char delim_r,
bool returnDelim_r =
false );
284 bool stderrGetline( std::string & retval_r,
bool returnDelim_r =
false )
299 class ZYPP_LOCAL ExternalProgramWithSeperatePgid :
public ExternalProgram
302 ExternalProgramWithSeperatePgid (
const char *
const *argv,
303 Stderr_Disposition stderr_disp = Normal_Stderr,
304 int stderr_fd = -1,
bool default_locale =
false,
305 const Pathname& root =
"") : ExternalProgram()
307 start_program( argv, Environment(), stderr_disp, stderr_fd, default_locale, root.c_str(),
true );
bool stderrGetUpTo(std::string &retval_r, const char delim_r, bool returnDelim_r=false)
Read data up to delim_r from stderr (nonblocking).
ExternalProgramWithStderr(const Arguments &argv_r, bool defaultLocale_r=false, const Pathname &root_r="")
void _initStdErr()
Close write end of the pipe (childs end).
bool stderrGetline(std::string &retval_r, bool returnDelim_r=false)
Read next complete line from stderr (nonblocking).
ExternalProgram()
Start an external program by giving the arguments as an arry of char *pointers.
const std::string & command() const
The command we're executing.
std::ostream & operator>>(std::ostream &out_r)
Redirect all command output to an ostream.
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
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, bool switch_pgid=false, bool die_with_parent=false, bool usePty=false)
static void renumber_fd(int origfd, int newfd)
origfd will be accessible as newfd and closed (unless they were equal)
std::vector< std::string > Arguments
bool kill()
Kill the program.
const std::string & execError() const
Some detail telling why the execution failed, if it failed.
bool running()
Return whether program is running.
int close()
Wait for the progamm to complete.
Stderr_Disposition
Define symbols for different policies on the handling of stderr.
std::unique_ptr< zyppng::AbstractSpawnEngine > _backend
Bidirectional stream to external data.
Easy-to use interface to the ZYPP dependency resolver.