libzypp 17.37.10

zyppng::AbstractSpawnEngine Class Referenceabstract

`#include <zypp-core/zyppng/io/private/abstractspawnengine_p.h>`

Inheritance diagram for zyppng::AbstractSpawnEngine:

## Public Types
using | Environment = std::map<std::string,std::string>
| For passing additional environment variables to set.

## Public Member Functions
| AbstractSpawnEngine ()
virtual | ~AbstractSpawnEngine ()
int | exitStatus () const
void | setExitStatus (const int state)
const std::string & | executedCommand () const
const std::string & | execError () const
void | setExecError (const std::string &str)
zypp::Pathname | chroot () const
void | setChroot (const zypp::Pathname &chroot)
bool | useDefaultLocale () const
void | setUseDefaultLocale (bool defaultLocale)
Environment | environment () const
void | setEnvironment (const Environment &environment)
pid_t | pid ()
virtual bool | start (const char *const *argv, int stdin_fd, int stdout_fd, int stderr_fd)=0
virtual bool | waitForExit (const std::optional< uint64_t > &timeout={})=0
virtual bool | isRunning (bool wait=false)=0
virtual void | notifyExited (int status)
bool | dieWithParent () const
void | setDieWithParent (bool dieWithParent)
bool | switchPgid () const
void | setSwitchPgid (bool switchPgid)
zypp::Pathname | workingDirectory () const
void | setWorkingDirectory (const zypp::Pathname &workingDirectory)
const std::vector< int > & | fdsToMap () const
void | addFd (int fd)
int | checkStatus (int status)

## Static Public Member Functions
static std::unique_ptr< zyppng::AbstractSpawnEngine > | createDefaultEngine ()

## Protected Attributes
bool | _useDefaultLocale = false
bool | _dieWithParent = false
| Should the process die with the parent process.
bool | _switchPgid = false
pid_t | _pid = -1
int | _exitStatus = 0
std::string | _execError
| Remember execution errors like failed fork/exec.
std::string | _executedCommand
| Store the command we're executing.
std::vector< std::string > | _args
| The arguments we want to pass to the program.
Environment | _environment
| Environment variables to set in the new process.
zypp::Pathname | _chroot
| Path to chroot into.
zypp::Pathname | _workingDirectory
| Working directory.
std::vector< int > | _mapFds
| Additional file descriptors we want to map to the new process.

## Detailed Description

This implements the basic skeleton of ExternalProgram and Process. Taking care of forking the process and setting up stdout and stderr so both implementations can use the same code

Definition at line 21 of file abstractspawnengine_p.h.

## Member Typedef Documentation

## ◆ Environment

using zyppng::AbstractSpawnEngine::Environment = std::map<std::string,std::string>

For passing additional environment variables to set.

Definition at line 28 of file abstractspawnengine_p.h.

## Constructor & Destructor Documentation

## ◆ AbstractSpawnEngine()

zyppng::AbstractSpawnEngine::AbstractSpawnEngine | ( |  | ) |

Definition at line 57 of file abstractspawnengine.cc.

## ◆ ~AbstractSpawnEngine()

zyppng::AbstractSpawnEngine::~AbstractSpawnEngine | ( |  | ) |
| virtual

Definition at line 61 of file abstractspawnengine.cc.

## Member Function Documentation

## ◆ createDefaultEngine()

std::unique_ptr< AbstractSpawnEngine > zyppng::AbstractSpawnEngine::createDefaultEngine | ( |  | ) |
| static

Definition at line 64 of file abstractspawnengine.cc.

## ◆ exitStatus()

int zyppng::AbstractSpawnEngine::exitStatus | ( |  | ) | const

Definition at line 115 of file abstractspawnengine.cc.

## ◆ setExitStatus()

void zyppng::AbstractSpawnEngine::setExitStatus | ( | const int | state | ) |

Definition at line 120 of file abstractspawnengine.cc.

## ◆ executedCommand()

const std::string & zyppng::AbstractSpawnEngine::executedCommand | ( |  | ) | const

Definition at line 125 of file abstractspawnengine.cc.

## ◆ execError()

const std::string & zyppng::AbstractSpawnEngine::execError | ( |  | ) | const

Definition at line 130 of file abstractspawnengine.cc.

## ◆ setExecError()

void zyppng::AbstractSpawnEngine::setExecError | ( | const std::string & | str | ) |

Definition at line 135 of file abstractspawnengine.cc.

## ◆ chroot()

zypp::Pathname zyppng::AbstractSpawnEngine::chroot | ( |  | ) | const

Definition at line 140 of file abstractspawnengine.cc.

## ◆ setChroot()

void zyppng::AbstractSpawnEngine::setChroot | ( | const zypp::Pathname & | chroot | ) |

Definition at line 145 of file abstractspawnengine.cc.

## ◆ useDefaultLocale()

bool zyppng::AbstractSpawnEngine::useDefaultLocale | ( |  | ) | const

Definition at line 150 of file abstractspawnengine.cc.

## ◆ setUseDefaultLocale()

void zyppng::AbstractSpawnEngine::setUseDefaultLocale | ( | bool | defaultLocale | ) |

Definition at line 155 of file abstractspawnengine.cc.

## ◆ environment()

AbstractSpawnEngine::Environment zyppng::AbstractSpawnEngine::environment | ( |  | ) | const

Definition at line 160 of file abstractspawnengine.cc.

## ◆ setEnvironment()

void zyppng::AbstractSpawnEngine::setEnvironment | ( | const Environment & | environment | ) |

Definition at line 165 of file abstractspawnengine.cc.

## ◆ pid()

pid_t zyppng::AbstractSpawnEngine::pid | ( |  | ) |

Returns
  the pid of the forked process, without checking if the process is still running.

Definition at line 170 of file abstractspawnengine.cc.

## ◆ start()

virtual bool zyppng::AbstractSpawnEngine::start | ( | const char *const * | argv,
|  | int | stdin_fd,
|  | int | stdout_fd,
|  | int | stderr_fd )
| pure virtual

Kickstart the process, if this returns true it is guaranteed that exec() was successful

Implemented in zyppng::ForkSpawnEngine.

## ◆ waitForExit()

virtual bool zyppng::AbstractSpawnEngine::waitForExit | ( | const std::optional< uint64_t > & | timeout = {} | ) |
| pure virtual

Implemented in zyppng::AbstractDirectSpawnEngine.

## ◆ isRunning()

virtual bool zyppng::AbstractSpawnEngine::isRunning | ( | bool | wait = false | ) |
| pure virtual

Implemented in zyppng::AbstractDirectSpawnEngine.

## ◆ notifyExited()

void zyppng::AbstractSpawnEngine::notifyExited | ( | int | status | ) |
| virtual

Used to notify the backend that the process has ended, helpful when the process is tracked in another way than calling isRunning, for example in a eventloop.

Definition at line 99 of file abstractspawnengine.cc.

## ◆ dieWithParent()

bool zyppng::AbstractSpawnEngine::dieWithParent | ( |  | ) | const

Definition at line 105 of file abstractspawnengine.cc.

## ◆ setDieWithParent()

void zyppng::AbstractSpawnEngine::setDieWithParent | ( | bool | dieWithParent | ) |

Definition at line 110 of file abstractspawnengine.cc.

## ◆ switchPgid()

bool zyppng::AbstractSpawnEngine::switchPgid | ( |  | ) | const

Definition at line 69 of file abstractspawnengine.cc.

## ◆ setSwitchPgid()

void zyppng::AbstractSpawnEngine::setSwitchPgid | ( | bool | switchPgid | ) |

Definition at line 74 of file abstractspawnengine.cc.

## ◆ workingDirectory()

zypp::Pathname zyppng::AbstractSpawnEngine::workingDirectory | ( |  | ) | const

Definition at line 79 of file abstractspawnengine.cc.

## ◆ setWorkingDirectory()

void zyppng::AbstractSpawnEngine::setWorkingDirectory | ( | const zypp::Pathname & | workingDirectory | ) |

Definition at line 84 of file abstractspawnengine.cc.

## ◆ fdsToMap()

const std::vector< int > & zyppng::AbstractSpawnEngine::fdsToMap | ( |  | ) | const

Definition at line 89 of file abstractspawnengine.cc.

## ◆ addFd()

void zyppng::AbstractSpawnEngine::addFd | ( | int | fd | ) |

Definition at line 94 of file abstractspawnengine.cc.

## ◆ checkStatus()

int zyppng::AbstractSpawnEngine::checkStatus | ( | int | status | ) |

Definition at line 175 of file abstractspawnengine.cc.

## Member Data Documentation

## ◆ _useDefaultLocale

bool zyppng::AbstractSpawnEngine::_useDefaultLocale = false
| protected

Definition at line 87 of file abstractspawnengine_p.h.

## ◆ _dieWithParent

bool zyppng::AbstractSpawnEngine::_dieWithParent = false
| protected

Should the process die with the parent process.

Definition at line 89 of file abstractspawnengine_p.h.

## ◆ _switchPgid

bool zyppng::AbstractSpawnEngine::_switchPgid = false
| protected

Definition at line 91 of file abstractspawnengine_p.h.

## ◆ _pid

pid_t zyppng::AbstractSpawnEngine::_pid = -1
| protected

Definition at line 93 of file abstractspawnengine_p.h.

## ◆ _exitStatus

int zyppng::AbstractSpawnEngine::_exitStatus = 0
| protected

Definition at line 94 of file abstractspawnengine_p.h.

## ◆ _execError

std::string zyppng::AbstractSpawnEngine::_execError
| protected

Remember execution errors like failed fork/exec.

Definition at line 96 of file abstractspawnengine_p.h.

## ◆ _executedCommand

std::string zyppng::AbstractSpawnEngine::_executedCommand
| protected

Store the command we're executing.

Definition at line 98 of file abstractspawnengine_p.h.

## ◆ _args

std::vector<std::string> zyppng::AbstractSpawnEngine::_args
| protected

The arguments we want to pass to the program.

Definition at line 100 of file abstractspawnengine_p.h.

## ◆ _environment

Environment zyppng::AbstractSpawnEngine::_environment
| protected

Environment variables to set in the new process.

Definition at line 102 of file abstractspawnengine_p.h.

## ◆ _chroot

zypp::Pathname zyppng::AbstractSpawnEngine::_chroot
| protected

Path to chroot into.

Definition at line 104 of file abstractspawnengine_p.h.

## ◆ _workingDirectory

zypp::Pathname zyppng::AbstractSpawnEngine::_workingDirectory
| protected

Working directory.

Definition at line 106 of file abstractspawnengine_p.h.

## ◆ _mapFds

std::vector<int> zyppng::AbstractSpawnEngine::_mapFds
| protected

Additional file descriptors we want to map to the new process.

Definition at line 108 of file abstractspawnengine_p.h.

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

- zypp-core/zyppng/io/private/abstractspawnengine_p.h
- zypp-core/zyppng/io/abstractspawnengine.cc