libzypp 17.35.11
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
12namespace 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
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;
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 _chroot
Path to chroot into.
virtual bool isRunning(bool wait=false)=0
void setSwitchPgid(bool switchPgid)
const std::string & executedCommand() const
const std::vector< int > & fdsToMap() const
zypp::Pathname workingDirectory() const
void setExecError(const std::string &str)
zypp::Pathname _workingDirectory
Working directory.
std::string _execError
Remember execution errors like failed fork/exec.
std::string _executedCommand
Store the command we're executing.
virtual bool start(const char *const *argv, int stdin_fd, int stdout_fd, int stderr_fd)=0
bool _dieWithParent
Should the process die with the parent process.
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.
void setExitStatus(const int state)
void setChroot(const zypp::Pathname &chroot)
virtual bool waitForExit(const std::optional< uint64_t > &timeout={})=0
virtual void notifyExited(int status)
Environment _environment
Environment variables to set in the new process.
void setWorkingDirectory(const zypp::Pathname &workingDirectory)
void setUseDefaultLocale(bool defaultLocale)
static std::unique_ptr< zyppng::AbstractSpawnEngine > createDefaultEngine()
std::vector< std::string > _args
The arguments we want to pass to the program.
void setEnvironment(const Environment &environment)
const std::string & execError() const
void setDieWithParent(bool dieWithParent)
String related utilities and Regular expression matching.