13#ifndef ZYPP_EXTERNALPROGRAM_H
14#define ZYPP_EXTERNALPROGRAM_H
28 class AbstractSpawnEngine;
69 using Arguments = std::vector<std::string>;
85 using Environment = std::map<std::string, std::string>;
96 Stderr_Disposition stderr_disp = Normal_Stderr,
97 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
125 Stderr_Disposition stderr_disp = Normal_Stderr,
126 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
129 ExternalProgram (
const Arguments &argv,
const Environment & environment,
130 Stderr_Disposition stderr_disp = Normal_Stderr,
131 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
135 Stderr_Disposition stderr_disp = Normal_Stderr,
136 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
139 ExternalProgram (
const char *
const *argv,
const Environment & environment,
140 Stderr_Disposition stderr_disp = Normal_Stderr,
141 bool use_pty =
false,
int stderr_fd = -1,
bool default_locale =
false,
145 bool use_pty =
false);
148 ExternalProgram (
const char *binpath,
const char *
const *argv_1,
const Environment & environment,
149 bool use_pty =
false);
154#ifdef __cpp_lib_optional
163 bool waitForExit ( std::optional<uint64_t> timeout = {} );
167 int close()
override;
177 bool kill(
int sig );
190 const std::string & command()
const;
201 const std::string & execError()
const;
206 static void renumber_fd (
int origfd,
int newfd);
228 std::ostream &
operator>>( std::ostream & out_r );
231 std::unique_ptr<zyppng::AbstractSpawnEngine> _backend;
235 void start_program (
const char *
const *argv,
const Environment & environment,
237 int stderr_fd = -1,
bool default_locale =
false,
238 const char* root = NULL,
bool switch_pgid =
false,
bool die_with_parent =
false,
bool usePty =
false );
243 namespace externalprogram
292 bool stderrGetUpTo( std::string & retval_r,
const char delim_r,
bool returnDelim_r =
false );
297 bool stderrGetline( std::string & retval_r,
bool returnDelim_r =
false )
317 int stderr_fd = -1,
bool default_locale =
false,
320 start_program( argv,
Environment(), stderr_disp, stderr_fd, default_locale, root.c_str(),
true );
ExternalProgram extended to change the progress group ID after forking.
ExternalProgram extended to offer reading programs stderr.
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).
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
Stderr_Disposition
Define symbols for different policies on the handling of stderr.
std::istream & operator>>(std::istream &str, PluginFrame &obj)
Construct from stream.
Bidirectional stream to external data.
Easy-to use interface to the ZYPP dependency resolver.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Helper providing pipe FDs for ExternalProgramWithStderr.
Provides API related macros.