libzypp: zyppng::Process Class Reference

libzypp 17.38.13

zyppng::Process Class Reference

`#include <zypp-core/ng/io/process.h>`

Inheritance diagram for zyppng::Process:

## Public Types
enum | OutputChannelMode { Seperate , Merged }
enum | OutputChannel { StdOut = 0 , StdErr = 1 }
using | Environment = std::map<std::string,std::string>
| For passing additional environment variables to set.
using | Ptr = ProcessRef
using | WeakPtr = ProcessWeakRef
Public Types inherited from zyppng::AsyncDataSource
enum | ChannelCloseReason { RemoteClose , AccessError , InternalError , UserRequest }
using | Ptr = std::shared_ptr<AsyncDataSource>
using | WeakPtr = std::weak_ptr<AsyncDataSource>
Public Types inherited from zyppng::IODevice
enum | OpenModeFlag { Closed = 0x0 , ReadOnly = 0x1 , WriteOnly = 0x2 , ReadWrite = ReadOnly | WriteOnly }
using | Ptr = std::shared_ptr<IODevice>
using | WeakPtr = std::weak_ptr<IODevice>
Public Types inherited from zyppng::Base
using | Ptr = std::shared_ptr<Base>
using | WeakPtr = std::weak_ptr<Base>

## Public Member Functions
| ~Process () override
bool | start (const char *const *argv)
void | stop (int signal=SIGTERM)
bool | isRunning ()
void | close () override
void | waitForExit ()
void | closeWriteChannel () override
const std::string & | executedCommand () const
const std::string & | execError () const
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 ()
int | exitStatus () const
bool | dieWithParent () const
void | setDieWithParent (bool enabled)
bool | switchPgid () const
void | setSwitchPgid (bool enabled)
zypp::Pathname | workingDirectory () const
void | setWorkingDirectory (const zypp::Pathname &workingDirectory)
const std::vector< int > & | fdsToMap () const
void | addFd (int fd)
int | stdinFd ()
int | stdoutFd ()
int | stderrFd ()
SignalProxy< void()> | sigStarted ()
SignalProxy< void()> | sigFailedToStart ()
SignalProxy< void(int)> | sigFinished ()
OutputChannelMode | outputChannelMode () const
void | setOutputChannelMode (const OutputChannelMode &outputChannelMode)
Public Member Functions inherited from zyppng::AsyncDataSource
bool | openFds (const std::vector< int > &readFds, int writeFd=-1)
bool | waitForReadyRead (uint channel, int timeout) override
void | flush ()
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> | sigWriteFdClosed ()
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> | sigReadFdClosed ()
bool | readFdOpen () const
bool | readFdOpen (uint channel) const
int64_t | bytesPending () const override
bool | waitForReadyRead (int timeout)
Public Member Functions inherited from zyppng::IODevice
| ZYPP_DECLARE_FLAGS (OpenMode, OpenModeFlag)
| IODevice ()
void | setReadChannel (uint channel)
uint | currentReadChannel () const
int | readChannelCount () const
bool | canRead () const
bool | canWrite () const
bool | isOpen () const
ByteArray | readAll ()
ByteArray | read (int64_t maxSize)
int64_t | read (char *buf, int64_t maxSize)
virtual ByteArray | readLine (const int64_t maxSize=0)
virtual int64_t | bytesAvailable () const
int64_t | readBufferCount () const
bool | canReadLine () const
ByteArray | readAll (uint channel)
ByteArray | read (uint channel, int64_t maxSize)
int64_t | read (uint channel, char *buf, int64_t maxSize)
ByteArray | channelReadUntil (uint channel, const char delim, int64_t maxSize=0)
ByteArray | channelReadLine (uint channel, int64_t maxSize=0)
int64_t | channelReadLine (uint channel, char *buf, const int64_t maxSize)
virtual int64_t | bytesAvailable (uint channel) const
int64_t | readBufferCount (uint channel) const
virtual int64_t | channelReadUntil (uint channel, char *buf, const char delimiter, const int64_t maxSize)
bool | canReadLine (uint channel) const
bool | canReadUntil (uint channel, const char delim) const
int64_t | write (const ByteArray &data)
int64_t | write (const char *data, int64_t len)
bool | waitForReadyRead (int timeout)
SignalProxy< void()> | sigReadyRead ()
SignalProxy< void(uint)> | sigChannelReadyRead ()
SignalProxy< void(int64_t)> | sigBytesWritten ()
SignalProxy< void()> | sigAllBytesWritten ()
SignalProxy< void(uint) > | sigReadChannelFinished ()
Public Member Functions inherited from zyppng::Base
| Base ()
virtual | ~Base ()
WeakPtr | parent () const
void | addChild (const Base::Ptr &child)
void | removeChild (const Ptr &child)
const std::unordered_set< Ptr > & | children () const
std::thread::id | threadId () const
template<typename T>
std::vector< std::weak_ptr< T > > | findChildren () const
template<typename T>
std::shared_ptr< T > | shared_this () const
template<typename T>
std::shared_ptr< T > | shared_this ()
template<typename T>
std::weak_ptr< T > | weak_this () const
template<typename T>
std::weak_ptr< T > | weak_this ()
template<typename SenderFunc, typename ReceiverFunc>
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
void | setData (uint32_t quark, zypp::AutoDispose< void * > data)
void * | data (uint32_t quark)
void | clearData (uint32_t quark)

## Static Public Member Functions
static Ptr | create ()
Static Public Member Functions inherited from zyppng::AsyncDataSource
static Ptr | create ()
Static Public Member Functions inherited from zyppng::Base
template<typename Obj, typename Functor>
static decltype(auto) | make_base_slot (Obj *o, Functor &&f)
template<typename SenderFunc, typename ReceiverFunc>
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)

## Protected Member Functions
| Process ()
Protected Member Functions inherited from zyppng::AsyncDataSource
| AsyncDataSource ()
| AsyncDataSource (AsyncDataSourcePrivate &d)
int64_t | writeData (const char *data, int64_t count) override
Protected Member Functions inherited from zyppng::IODevice
| IODevice (IODevicePrivate &d)
void | setReadChannelCount (uint channels)
void | finishReadChannel (uint channel)
Protected Member Functions inherited from zyppng::Base
| Base (BasePrivate &dd)

## Additional Inherited Members
Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivate > | d_ptr

## Detailed Description

Definition at line 31 of file process.h.

## Member Typedef Documentation

## ◆ Environment

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

For passing additional environment variables to set.

Definition at line 38 of file process.h.

## ◆ Ptr

using zyppng::Process::Ptr = ProcessRef

Definition at line 39 of file process.h.

## ◆ WeakPtr

using zyppng::Process::WeakPtr = ProcessWeakRef

Definition at line 40 of file process.h.

## Member Enumeration Documentation

## ◆ OutputChannelMode

enum zyppng::Process::OutputChannelMode

Enumerator
Seperate |
Merged |

Definition at line 42 of file process.h.

## ◆ OutputChannel

enum zyppng::Process::OutputChannel

Enumerator
StdOut |
StdErr |

Definition at line 47 of file process.h.

## Constructor & Destructor Documentation

## ◆ ~Process()

zyppng::Process::~Process | ( |  | ) |
| override

Definition at line 54 of file process.cpp.

## ◆ Process()

zyppng::Process::Process | ( |  | ) |
| protected

Definition at line 44 of file process.cpp.

## Member Function Documentation

## ◆ create()

Process::Ptr zyppng::Process::create | ( |  | ) |
| static

Definition at line 49 of file process.cpp.

## ◆ start()

bool zyppng::Process::start | ( | const char *const * | argv | ) |

Definition at line 63 of file process.cpp.

## ◆ stop()

void zyppng::Process::stop | ( | int | signal = SIGTERM | ) |

Definition at line 139 of file process.cpp.

## ◆ isRunning()

bool zyppng::Process::isRunning | ( |  | ) |

Definition at line 147 of file process.cpp.

## ◆ close()

void zyppng::Process::close | ( |  | ) |
| overridevirtual

Closes the AsyncDataSource and releases the used fd's to the calling code. They are NOT closed.

Reimplemented from zyppng::AsyncDataSource.

Definition at line 153 of file process.cpp.

## ◆ waitForExit()

void zyppng::Process::waitForExit | ( |  | ) |

Blocks until the process has exited, during that time readyRead is not emitted for any read channels. Call readAll to get all remaining data that was written by the process

Definition at line 161 of file process.cpp.

## ◆ closeWriteChannel()

void zyppng::Process::closeWriteChannel | ( |  | ) |
| overridevirtual

Close the stdin fd of the subprocess. This is required for processes that run until their stdin is closed.

Reimplemented from zyppng::AsyncDataSource.

Definition at line 172 of file process.cpp.

## ◆ executedCommand()

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

Definition at line 179 of file process.cpp.

## ◆ execError()

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

Definition at line 184 of file process.cpp.

## ◆ chroot()

zypp::filesystem::Pathname zyppng::Process::chroot | ( |  | ) | const

Definition at line 189 of file process.cpp.

## ◆ setChroot()

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

Definition at line 194 of file process.cpp.

## ◆ useDefaultLocale()

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

Definition at line 199 of file process.cpp.

## ◆ setUseDefaultLocale()

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

Definition at line 204 of file process.cpp.

## ◆ environment()

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

Definition at line 209 of file process.cpp.

## ◆ setEnvironment()

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

Definition at line 214 of file process.cpp.

## ◆ pid()

pid_t zyppng::Process::pid | ( |  | ) |

Definition at line 219 of file process.cpp.

## ◆ exitStatus()

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

Definition at line 224 of file process.cpp.

## ◆ dieWithParent()

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

Definition at line 229 of file process.cpp.

## ◆ setDieWithParent()

void zyppng::Process::setDieWithParent | ( | bool | enabled | ) |

Definition at line 234 of file process.cpp.

## ◆ switchPgid()

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

Definition at line 239 of file process.cpp.

## ◆ setSwitchPgid()

void zyppng::Process::setSwitchPgid | ( | bool | enabled | ) |

Definition at line 244 of file process.cpp.

## ◆ workingDirectory()

zypp::filesystem::Pathname zyppng::Process::workingDirectory | ( |  | ) | const

Definition at line 249 of file process.cpp.

## ◆ setWorkingDirectory()

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

Definition at line 254 of file process.cpp.

## ◆ fdsToMap()

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

Definition at line 259 of file process.cpp.

## ◆ addFd()

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

Definition at line 264 of file process.cpp.

## ◆ stdinFd()

int zyppng::Process::stdinFd | ( |  | ) |

Definition at line 269 of file process.cpp.

## ◆ stdoutFd()

int zyppng::Process::stdoutFd | ( |  | ) |

Definition at line 274 of file process.cpp.

## ◆ stderrFd()

int zyppng::Process::stderrFd | ( |  | ) |

Definition at line 279 of file process.cpp.

## ◆ sigStarted()

SignalProxy< void()> zyppng::Process::sigStarted | ( |  | ) |

Definition at line 284 of file process.cpp.

## ◆ sigFailedToStart()

SignalProxy< void()> zyppng::Process::sigFailedToStart | ( |  | ) |

Definition at line 289 of file process.cpp.

## ◆ sigFinished()

SignalProxy< void(int)> zyppng::Process::sigFinished | ( |  | ) |

Definition at line 294 of file process.cpp.

## ◆ outputChannelMode()

Process::OutputChannelMode zyppng::Process::outputChannelMode | ( |  | ) | const

Definition at line 299 of file process.cpp.

## ◆ setOutputChannelMode()

void zyppng::Process::setOutputChannelMode | ( | const OutputChannelMode & | outputChannelMode | ) |

Definition at line 300 of file process.cpp.

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

- zypp-core/ng/io/process.h
- zypp-core/ng/io/process.cpp