libzypp  17.32.5
abstractspawnengine_p.h
Go to the documentation of this file.
1 #ifndef ZYPPNG_IO_PRIVATE_ABSTRACTPROCESSBACKEND_H
2 #define ZYPPNG_IO_PRIVATE_ABSTRACTPROCESSBACKEND_H
3 
4 #include <string>
5 #include <vector>
6 #include <map>
7 #include <memory>
8 #include <optional>
9 
10 #include <zypp/Pathname.h>
11 
12 namespace zyppng {
13 
21  {
22  public:
23 
27  using Environment = std::map<std::string,std::string>;
28 
30  virtual ~AbstractSpawnEngine();
31 
32  static std::unique_ptr<zyppng::AbstractSpawnEngine> createDefaultEngine ();
33 
34  int exitStatus () const;
35  void setExitStatus ( const int state );
36 
37  const std::string &executedCommand () const;
38  const std::string &execError() const;
39  void setExecError ( const std::string & str );
40 
41  zypp::Pathname chroot() const;
42  void setChroot( const zypp::Pathname &chroot );
43 
44  bool useDefaultLocale() const;
45  void setUseDefaultLocale( bool defaultLocale );
46 
47  Environment environment() const;
48  void setEnvironment( const Environment &environment );
49 
54  pid_t pid ( );
55 
59  virtual bool start ( const char *const *argv, int stdin_fd, int stdout_fd, int stderr_fd ) = 0;
60 
61  virtual bool waitForExit ( const std::optional<uint64_t> &timeout = {} ) = 0;
62  virtual bool isRunning ( bool wait = false ) = 0;
63 
69  virtual void notifyExited ( int status );
70 
71  bool dieWithParent() const;
72  void setDieWithParent( bool dieWithParent );
73 
74  bool switchPgid() const;
75  void setSwitchPgid(bool switchPgid);
76 
79 
80  const std::vector<int> &fdsToMap () const;
81  void addFd ( int fd );
82 
83  int checkStatus(int status);
84 
85  protected:
86  bool _useDefaultLocale = false;
88  bool _dieWithParent = false;
89 
90  bool _switchPgid = false;
91 
92  pid_t _pid = -1;
93  int _exitStatus = 0;
95  std::string _execError;
97  std::string _executedCommand;
99  std::vector<std::string> _args;
107  std::vector<int> _mapFds;
108 
109  };
110 
111 } // namespace zyppng
112 
113 #endif // ZYPPNG_IO_PRIVATE_ABSTRACTPROCESSBACKEND_H
zypp::Pathname workingDirectory() const
zypp::Pathname _workingDirectory
Working directory.
virtual void notifyExited(int status)
static std::unique_ptr< zyppng::AbstractSpawnEngine > createDefaultEngine()
std::string _execError
Remember execution errors like failed fork/exec.
const std::string & execError() const
String related utilities and Regular expression matching.
void setUseDefaultLocale(bool defaultLocale)
bool _dieWithParent
Should the process die with the parent process.
virtual bool start(const char *const *argv, int stdin_fd, int stdout_fd, int stderr_fd)=0
void setWorkingDirectory(const zypp::Pathname &workingDirectory)
std::vector< std::string > _args
The arguments we want to pass to the program.
void setExecError(const std::string &str)
void setEnvironment(const Environment &environment)
void setChroot(const zypp::Pathname &chroot)
zypp::Pathname _chroot
Path to chroot into.
void setDieWithParent(bool dieWithParent)
std::string _executedCommand
Store the command we&#39;re executing.
virtual bool waitForExit(const std::optional< uint64_t > &timeout={})=0
zypp::Pathname chroot() const
void setExitStatus(const int state)
const std::string & executedCommand() const
virtual bool isRunning(bool wait=false)=0
void setSwitchPgid(bool switchPgid)
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
std::vector< int > _mapFds
Additional file descriptors we want to map to the new process.
const std::vector< int > & fdsToMap() const
Environment _environment
Environment variables to set in the new process.