libzypp: zypp-core/ng/io/private/abstractspawnengine_p.h Source File

libzypp 17.38.13

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-core/Pathname.h>
12
13namespace zyppng {
14
21 class AbstractSpawnEngine
22 {
23 public:
24
28 using Environment = std::map<std::string,std::string>;
29
30 AbstractSpawnEngine();
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
48 Environment environment() const;
49 void setEnvironment( const Environment &environment );
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;
73 void setDieWithParent( bool dieWithParent );
74
75 bool switchPgid() const;
76 void setSwitchPgid(bool switchPgid);
77
78 zypp::Pathname workingDirectory() const;
79 void setWorkingDirectory(const zypp::Pathname &workingDirectory);
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::optional<std::string> _childExecDetail;
100 std::string _executedCommand;
102 std::vector<std::string> _args;
104 Environment _environment;
106 zypp::Pathname _chroot;
108 zypp::Pathname _workingDirectory;
110 std::vector<int> _mapFds;
111
112 };
113
114} // namespace zyppng
115
116#endif // ZYPPNG_IO_PRIVATE_ABSTRACTPROCESSBACKEND_H
Pathname.h
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zyppng::AbstractSpawnEngine::pid
pid_t pid()
Definition abstractspawnengine.cc:170
zyppng::AbstractSpawnEngine::_chroot
zypp::Pathname _chroot
Path to chroot into.
Definition abstractspawnengine_p.h:106
zyppng::AbstractSpawnEngine::isRunning
virtual bool isRunning(bool wait=false)=0
zyppng::AbstractSpawnEngine::dieWithParent
bool dieWithParent() const
Definition abstractspawnengine.cc:105
zyppng::AbstractSpawnEngine::setSwitchPgid
void setSwitchPgid(bool switchPgid)
Definition abstractspawnengine.cc:74
zyppng::AbstractSpawnEngine::executedCommand
const std::string & executedCommand() const
Definition abstractspawnengine.cc:125
zyppng::AbstractSpawnEngine::AbstractSpawnEngine
AbstractSpawnEngine()
Definition abstractspawnengine.cc:57
zyppng::AbstractSpawnEngine::environment
Environment environment() const
Definition abstractspawnengine.cc:160
zyppng::AbstractSpawnEngine::fdsToMap
const std::vector< int > & fdsToMap() const
Definition abstractspawnengine.cc:89
zyppng::AbstractSpawnEngine::workingDirectory
zypp::Pathname workingDirectory() const
Definition abstractspawnengine.cc:79
zyppng::AbstractSpawnEngine::setExecError
void setExecError(const std::string &str)
Definition abstractspawnengine.cc:135
zyppng::AbstractSpawnEngine::switchPgid
bool switchPgid() const
Definition abstractspawnengine.cc:69
zyppng::AbstractSpawnEngine::_workingDirectory
zypp::Pathname _workingDirectory
Working directory.
Definition abstractspawnengine_p.h:108
zyppng::AbstractSpawnEngine::_execError
std::string _execError
Remember execution errors like failed fork/exec.
Definition abstractspawnengine_p.h:96
zyppng::AbstractSpawnEngine::_executedCommand
std::string _executedCommand
Store the command we're executing.
Definition abstractspawnengine_p.h:100
zyppng::AbstractSpawnEngine::_exitStatus
int _exitStatus
Definition abstractspawnengine_p.h:94
zyppng::AbstractSpawnEngine::start
virtual bool start(const char *const *argv, int stdin_fd, int stdout_fd, int stderr_fd)=0
zyppng::AbstractSpawnEngine::_dieWithParent
bool _dieWithParent
Should the process die with the parent process.
Definition abstractspawnengine_p.h:89
zyppng::AbstractSpawnEngine::_switchPgid
bool _switchPgid
Definition abstractspawnengine_p.h:91
zyppng::AbstractSpawnEngine::~AbstractSpawnEngine
virtual ~AbstractSpawnEngine()
Definition abstractspawnengine.cc:61
zyppng::AbstractSpawnEngine::Environment
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
Definition abstractspawnengine_p.h:28
zyppng::AbstractSpawnEngine::_childExecDetail
std::optional< std::string > _childExecDetail
Error detail to remember if checkStatus sets an _execError.
Definition abstractspawnengine_p.h:98
zyppng::AbstractSpawnEngine::_useDefaultLocale
bool _useDefaultLocale
Definition abstractspawnengine_p.h:87
zyppng::AbstractSpawnEngine::_mapFds
std::vector< int > _mapFds
Additional file descriptors we want to map to the new process.
Definition abstractspawnengine_p.h:110
zyppng::AbstractSpawnEngine::setExitStatus
void setExitStatus(const int state)
Definition abstractspawnengine.cc:120
zyppng::AbstractSpawnEngine::setChroot
void setChroot(const zypp::Pathname &chroot)
Definition abstractspawnengine.cc:145
zyppng::AbstractSpawnEngine::waitForExit
virtual bool waitForExit(const std::optional< uint64_t > &timeout={})=0
zyppng::AbstractSpawnEngine::notifyExited
virtual void notifyExited(int status)
Definition abstractspawnengine.cc:99
zyppng::AbstractSpawnEngine::addFd
void addFd(int fd)
Definition abstractspawnengine.cc:94
zyppng::AbstractSpawnEngine::_environment
Environment _environment
Environment variables to set in the new process.
Definition abstractspawnengine_p.h:104
zyppng::AbstractSpawnEngine::exitStatus
int exitStatus() const
Definition abstractspawnengine.cc:115
zyppng::AbstractSpawnEngine::_pid
pid_t _pid
Definition abstractspawnengine_p.h:93
zyppng::AbstractSpawnEngine::useDefaultLocale
bool useDefaultLocale() const
Definition abstractspawnengine.cc:150
zyppng::AbstractSpawnEngine::setWorkingDirectory
void setWorkingDirectory(const zypp::Pathname &workingDirectory)
Definition abstractspawnengine.cc:84
zyppng::AbstractSpawnEngine::checkStatus
int checkStatus(int status)
Definition abstractspawnengine.cc:175
zyppng::AbstractSpawnEngine::chroot
zypp::Pathname chroot() const
Definition abstractspawnengine.cc:140
zyppng::AbstractSpawnEngine::setUseDefaultLocale
void setUseDefaultLocale(bool defaultLocale)
Definition abstractspawnengine.cc:155
zyppng::AbstractSpawnEngine::createDefaultEngine
static std::unique_ptr< zyppng::AbstractSpawnEngine > createDefaultEngine()
Definition abstractspawnengine.cc:64
zyppng::AbstractSpawnEngine::_args
std::vector< std::string > _args
The arguments we want to pass to the program.
Definition abstractspawnengine_p.h:102
zyppng::AbstractSpawnEngine::setEnvironment
void setEnvironment(const Environment &environment)
Definition abstractspawnengine.cc:165
zyppng::AbstractSpawnEngine::execError
const std::string & execError() const
Definition abstractspawnengine.cc:130
zyppng::AbstractSpawnEngine::setDieWithParent
void setDieWithParent(bool dieWithParent)
Definition abstractspawnengine.cc:110
str
String related utilities and Regular expression matching.
zyppng
Definition MediaNetworkRequestExecutor.h:16