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>;
154#ifdef __cpp_lib_optional
163 bool waitForExit ( std::optional<uint64_t> timeout = {} );
167 int close()
override;
190 const std::string &
command()
const;
231 std::unique_ptr<zyppng::AbstractSpawnEngine>
_backend;
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 )
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
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 ...
ExternalProgram()
Start an external program by giving the arguments as an arry of char *pointers.
int close() override
Wait for the progamm to complete.
const std::string & command() const
The command we're executing.
std::ostream & operator>>(std::ostream &out_r)
Redirect all command output to an ostream.
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)
std::vector< std::string > Arguments
~ExternalProgram() override
static void renumber_fd(int origfd, int newfd)
origfd will be accessible as newfd and closed (unless they were equal)
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
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.
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.
Helper providing pipe FDs for ExternalProgramWithStderr.