libzypp 17.37.17
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 <cstdint>
5#include <string>
6#include <vector>
7#include <map>
8#include <memory>
9#include <optional>
10
11#include <zypp/Pathname.h>
12
13namespace zyppng {
14
22 {
23 public:
24
28 using Environment = std::map<std::string,std::string>;
29
31 virtual ~AbstractSpawnEngine();
32
33 static std::unique_ptr<zyppng::AbstractSpawnEngine> createDefaultEngine ();
34
35 int exitStatus () const;
36 void setExitStatus ( const int state );
37
38 const std::string &executedCommand () const;
39 const std::string &execError() const;
40 void setExecError ( const std::string & str );
41
42 zypp::Pathname chroot() const;
43 void setChroot( const zypp::Pathname &chroot );
44
45 bool useDefaultLocale() const;
46 void setUseDefaultLocale( bool defaultLocale );
47
50
55 pid_t pid ( );
56
60 virtual bool start ( const char *const *argv, int stdin_fd, int stdout_fd, int stderr_fd ) = 0;
61
62 virtual bool waitForExit ( const std::optional<uint64_t> &timeout = {} ) = 0;
63 virtual bool isRunning ( bool wait = false ) = 0;
64
70 virtual void notifyExited ( int status );
71
72 bool dieWithParent() const;
74
75 bool switchPgid() const;
76 void setSwitchPgid(bool switchPgid);
77
80
81 const std::vector<int> &fdsToMap () const;
82 void addFd ( int fd );
83
84 int checkStatus(int status);
85
86 protected:
87 bool _useDefaultLocale = false;
89 bool _dieWithParent = false;
90
91 bool _switchPgid = false;
92
93 pid_t _pid = -1;
94 int _exitStatus = 0;
96 std::string _execError;
98 std::string _executedCommand;
100 std::vector<std::string> _args;
108 std::vector<int> _mapFds;
109
110 };
111
112} // namespace zyppng
113
114#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.