libzypp 17.37.17
|
#include <zypp-core/zyppng/io/process.h>
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) |
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 |
using zyppng::Process::Environment = std::map<std::string,std::string> |
using zyppng::Process::Ptr = ProcessRef |
using zyppng::Process::WeakPtr = ProcessWeakRef |
|
override |
Definition at line 54 of file process.cpp.
|
protected |
Definition at line 44 of file process.cpp.
|
static |
Definition at line 49 of file process.cpp.
bool zyppng::Process::start | ( | const char *const * | argv | ) |
Definition at line 63 of file process.cpp.
void zyppng::Process::stop | ( | int | signal = SIGTERM | ) |
Definition at line 139 of file process.cpp.
bool zyppng::Process::isRunning | ( | ) |
Definition at line 147 of file process.cpp.
|
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.
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.
|
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.
const std::string & zyppng::Process::executedCommand | ( | ) | const |
Definition at line 179 of file process.cpp.
const std::string & zyppng::Process::execError | ( | ) | const |
Definition at line 184 of file process.cpp.
zypp::filesystem::Pathname zyppng::Process::chroot | ( | ) | const |
Definition at line 189 of file process.cpp.
void zyppng::Process::setChroot | ( | const zypp::Pathname & | chroot | ) |
Definition at line 194 of file process.cpp.
bool zyppng::Process::useDefaultLocale | ( | ) | const |
Definition at line 199 of file process.cpp.
void zyppng::Process::setUseDefaultLocale | ( | bool | defaultLocale | ) |
Definition at line 204 of file process.cpp.
Process::Environment zyppng::Process::environment | ( | ) | const |
Definition at line 209 of file process.cpp.
void zyppng::Process::setEnvironment | ( | const Environment & | environment | ) |
Definition at line 214 of file process.cpp.
pid_t zyppng::Process::pid | ( | ) |
Definition at line 219 of file process.cpp.
int zyppng::Process::exitStatus | ( | ) | const |
Definition at line 224 of file process.cpp.
bool zyppng::Process::dieWithParent | ( | ) | const |
Definition at line 229 of file process.cpp.
void zyppng::Process::setDieWithParent | ( | bool | enabled | ) |
Definition at line 234 of file process.cpp.
bool zyppng::Process::switchPgid | ( | ) | const |
Definition at line 239 of file process.cpp.
void zyppng::Process::setSwitchPgid | ( | bool | enabled | ) |
Definition at line 244 of file process.cpp.
zypp::filesystem::Pathname zyppng::Process::workingDirectory | ( | ) | const |
Definition at line 249 of file process.cpp.
void zyppng::Process::setWorkingDirectory | ( | const zypp::Pathname & | workingDirectory | ) |
Definition at line 254 of file process.cpp.
const std::vector< int > & zyppng::Process::fdsToMap | ( | ) | const |
Definition at line 259 of file process.cpp.
void zyppng::Process::addFd | ( | int | fd | ) |
Definition at line 264 of file process.cpp.
int zyppng::Process::stdinFd | ( | ) |
Definition at line 269 of file process.cpp.
int zyppng::Process::stdoutFd | ( | ) |
Definition at line 274 of file process.cpp.
int zyppng::Process::stderrFd | ( | ) |
Definition at line 279 of file process.cpp.
SignalProxy< void()> zyppng::Process::sigStarted | ( | ) |
Definition at line 284 of file process.cpp.
SignalProxy< void()> zyppng::Process::sigFailedToStart | ( | ) |
Definition at line 289 of file process.cpp.
SignalProxy< void(int)> zyppng::Process::sigFinished | ( | ) |
Definition at line 294 of file process.cpp.
Process::OutputChannelMode zyppng::Process::outputChannelMode | ( | ) | const |
Definition at line 299 of file process.cpp.
void zyppng::Process::setOutputChannelMode | ( | const OutputChannelMode & | outputChannelMode | ) |
Definition at line 300 of file process.cpp.