libzypp 17.31.7
zypp::ExternalProgramWithStderr Class Reference

ExternalProgram extended to offer reading programs stderr. More...

#include <ExternalProgram.h>

Inheritance diagram for zypp::ExternalProgramWithStderr:

Public Member Functions

 ExternalProgramWithStderr (const Arguments &argv_r, bool defaultLocale_r=false, const Pathname &root_r="")
 
 ExternalProgramWithStderr (const Arguments &argv_r, const Pathname &root_r)
 \overlocad Convenience taking just the root_r. More...
 
 ExternalProgramWithStderr (const Arguments &argv_r, const Environment &environment_r, bool defaultLocale_r=false, const Pathname &root_r="")
 
 ExternalProgramWithStderr (const Arguments &argv_r, const Environment &environment_r, const Pathname &root_r)
 \overlocad Convenience taking just the root_r. More...
 
bool stderrGetUpTo (std::string &retval_r, const char delim_r, bool returnDelim_r=false)
 Read data up to delim_r from stderr (nonblocking). More...
 
bool stderrGetline (std::string &retval_r, bool returnDelim_r=false)
 Read next complete line from stderr (nonblocking). More...
 
- Public Member Functions inherited from zypp::ExternalProgram
 ExternalProgram (std::string commandline, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="")
 Start the external program by using the shell /bin/sh with the option -c. More...
 
 ExternalProgram ()
 Start an external program by giving the arguments as an arry of char *pointers. More...
 
 ExternalProgram (const Arguments &argv, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="")
 
 ExternalProgram (const Arguments &argv, const Environment &environment, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="")
 
 ExternalProgram (const char *const *argv, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="")
 
 ExternalProgram (const char *const *argv, const Environment &environment, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="")
 
 ExternalProgram (const char *binpath, const char *const *argv_1, bool use_pty=false)
 
 ExternalProgram (const char *binpath, const char *const *argv_1, const Environment &environment, bool use_pty=false)
 
 ~ExternalProgram ()
 
int close ()
 Wait for the progamm to complete. More...
 
bool kill ()
 Kill the program. More...
 
bool kill (int sig)
 Send a signal to the program. More...
 
bool running ()
 Return whether program is running. More...
 
pid_t getpid ()
 return pid More...
 
const std::string & command () const
 The command we're executing. More...
 
const std::string & execError () const
 Some detail telling why the execution failed, if it failed. More...
 
std::ostream & operator>> (std::ostream &out_r)
 Redirect all command output to an ostream. More...
 
- Public Member Functions inherited from zypp::externalprogram::ExternalDataSource
 ExternalDataSource (FILE *inputfile=0, FILE *outputfile=0)
 Create a new instance. More...
 
virtual ~ExternalDataSource ()
 Implicitly close the connection. More...
 
bool send (const char *buffer, size_t length)
 Send some data to the output stream. More...
 
bool send (std::string s)
 Send some data down the stream. More...
 
size_t receive (char *buffer, size_t length)
 Read some data from the input stream. More...
 
std::string receiveLine ()
 Read one line from the input stream. More...
 
std::string receiveLine (io::timeout_type timeout)
 Read one line from the input stream. More...
 
std::string receiveUpto (char c)
 Read characters into a string until delimiter c or EOF is read. More...
 
std::string receiveUpto (char c, io::timeout_type timeout)
 Read characters into a string until delimiter c or EOF is read or the timeout is reached. More...
 
void setBlocking (bool mode)
 Set the blocking mode of the input stream. More...
 
virtual int close ()
 Close the input and output streams. More...
 
FILE * inputFile () const
 Return the input stream. More...
 
FILE * outputFile () const
 Return the output stream. More...
 

Private Member Functions

void _initStdErr ()
 Close write end of the pipe (childs end). More...
 
- Private Member Functions inherited from zypp::externalprogram::EarlyPipe
 EarlyPipe ()
 
 ~EarlyPipe ()
 
void closeW ()
 
FILE * fStdErr ()
 

Private Attributes

std::string _buffer
 
- Private Attributes inherited from zypp::externalprogram::EarlyPipe
FILE * _stderr
 
int _fds [2]
 

Additional Inherited Members

- Public Types inherited from zypp::ExternalProgram
enum  Stderr_Disposition { Normal_Stderr , Discard_Stderr , Stderr_To_Stdout , Stderr_To_FileDesc }
 Define symbols for different policies on the handling of stderr. More...
 
typedef std::vector< std::string > Arguments
 
typedef std::map< std::string, std::string > Environment
 For passing additional environment variables to set. More...
 
- Static Public Member Functions inherited from zypp::ExternalProgram
static void renumber_fd (int origfd, int newfd)
 origfd will be accessible as newfd and closed (unless they were equal) More...
 
- Protected Member Functions inherited from zypp::ExternalProgram
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)
 
- Protected Attributes inherited from zypp::externalprogram::ExternalDataSource
FILE * inputfile
 
FILE * outputfile
 
- Private Types inherited from zypp::externalprogram::EarlyPipe
enum  { R =0 , W =1 }
 

Detailed Description

ExternalProgram extended to offer reading programs stderr.

See also
ExternalProgram

Definition at line 253 of file ExternalProgram.h.

Constructor & Destructor Documentation

◆ ExternalProgramWithStderr() [1/4]

zypp::ExternalProgramWithStderr::ExternalProgramWithStderr ( const Arguments argv_r,
bool  defaultLocale_r = false,
const Pathname root_r = "" 
)
inline

Definition at line 256 of file ExternalProgram.h.

◆ ExternalProgramWithStderr() [2/4]

zypp::ExternalProgramWithStderr::ExternalProgramWithStderr ( const Arguments argv_r,
const Pathname root_r 
)
inline

\overlocad Convenience taking just the root_r.

Definition at line 260 of file ExternalProgram.h.

◆ ExternalProgramWithStderr() [3/4]

zypp::ExternalProgramWithStderr::ExternalProgramWithStderr ( const Arguments argv_r,
const Environment environment_r,
bool  defaultLocale_r = false,
const Pathname root_r = "" 
)
inline

Definition at line 264 of file ExternalProgram.h.

◆ ExternalProgramWithStderr() [4/4]

zypp::ExternalProgramWithStderr::ExternalProgramWithStderr ( const Arguments argv_r,
const Environment environment_r,
const Pathname root_r 
)
inline

\overlocad Convenience taking just the root_r.


Definition at line 268 of file ExternalProgram.h.

Member Function Documentation

◆ stderrGetUpTo()

bool zypp::ExternalProgramWithStderr::stderrGetUpTo ( std::string &  retval_r,
const char  delim_r,
bool  returnDelim_r = false 
)

Read data up to delim_r from stderr (nonblocking).

Note
If delim_r is '\0', we read as much data as possible.
Returns
false if data are not yet available (retval_r remains untouched then).

Definition at line 512 of file ExternalProgram.cc.

◆ stderrGetline()

bool zypp::ExternalProgramWithStderr::stderrGetline ( std::string &  retval_r,
bool  returnDelim_r = false 
)
inline

Read next complete line from stderr (nonblocking).

Returns
false if data are not yet available (retval_r remains untouched then).

Definition at line 284 of file ExternalProgram.h.

◆ _initStdErr()

void zypp::ExternalProgramWithStderr::_initStdErr ( )
inlineprivate

Close write end of the pipe (childs end).

Definition at line 289 of file ExternalProgram.h.

Member Data Documentation

◆ _buffer

std::string zypp::ExternalProgramWithStderr::_buffer
private

Definition at line 293 of file ExternalProgram.h.


The documentation for this class was generated from the following files: