3#include <zypp-core/zyppng/base/EventDispatcher>
5#include <zypp-core/zyppng/io/AsyncDataSource>
49 return std::shared_ptr<Process>(
new Process() );
55 if (
d->_spawnEngine->pid() >= 0 ) {
57 DBG <<
"Process destroyed while still running removing from EventLoop." << std::endl;
66 ERR <<
"A valid EventDispatcher needs to be registered before starting a Process" << std::endl;
80 d->_sigFailedToStart.emit();
86 d->_sigFailedToStart.emit();
95 d->_sigFailedToStart.emit();
106 const auto pid =
d->_spawnEngine->pid( );
111 d->_spawnEngine->notifyExited( status );
112 d->_sigFinished.emit(
d->_spawnEngine->exitStatus() );
116 d->_stdinFd = std::move(
stdinPipe->writeFd );
119 std::vector<int>
rFds {
d->_stdoutFd };
122 rFds.push_back(
d->_stderrFd.value() );
130 d->_sigStarted.emit();
133 d->_sigFailedToStart.emit();
141 ::kill(
d->_spawnEngine->pid(), signal );
148 return (
d->_spawnEngine->pid() > -1 );
162 if (
d->_spawnEngine->isRunning() ) {
166 d->_spawnEngine->isRunning(
true );
179 return d_func()->_spawnEngine->executedCommand();
184 return d_func()->_spawnEngine->execError();
189 return d_func()->_spawnEngine->chroot();
199 return d_func()->_spawnEngine->useDefaultLocale();
209 return d_func()->_spawnEngine->environment();
214 return d_func()->_spawnEngine->setEnvironment(
env );
219 return d_func()->_spawnEngine->pid();
224 return d_func()->_spawnEngine->exitStatus();
229 return d_func()->_spawnEngine->dieWithParent();
234 return d_func()->_spawnEngine->setDieWithParent( enabled );
239 return d_func()->_spawnEngine->switchPgid();
244 return d_func()->_spawnEngine->setSwitchPgid( enabled );
249 return d_func()->_spawnEngine->workingDirectory();
254 return d_func()->_spawnEngine->setWorkingDirectory(
wd );
259 return d_func()->_spawnEngine->fdsToMap();
264 return d_func()->_spawnEngine->addFd(
fd );
269 return d_func()->_stdinFd;
274 return d_func()->_stdoutFd;
279 return d_func()->_stderrFd;
284 return d_func()->_sigStarted;
289 return d_func()->_sigFailedToStart;
294 return d_func()->_sigFinished;
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
static std::unique_ptr< zyppng::AbstractSpawnEngine > createDefaultEngine()
bool openFds(const std::vector< int > &readFds, int writeFd=-1)
virtual void closeWriteChannel()
static std::shared_ptr< EventDispatcher > instance()
std::unique_ptr< AbstractSpawnEngine > _spawnEngine
Signal< void()> _sigFailedToStart
Signal< void(int)> _sigFinished
ProcessPrivate(Process &p)
Process::OutputChannel _currentChannel
Process::OutputChannelMode _channelMode
Signal< void()> _sigStarted
OutputChannelMode outputChannelMode() const
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
zypp::Pathname chroot() const
std::shared_ptr< Process > Ptr
bool dieWithParent() const
void setEnvironment(const Environment &environment)
void stop(int signal=SIGTERM)
void closeWriteChannel() override
const std::string & executedCommand() const
bool start(const char *const *argv)
bool useDefaultLocale() const
void setWorkingDirectory(const zypp::Pathname &workingDirectory)
SignalProxy< void()> sigStarted()
const std::vector< int > & fdsToMap() const
void setUseDefaultLocale(bool defaultLocale)
void setSwitchPgid(bool enabled)
void setChroot(const zypp::Pathname &chroot)
void setOutputChannelMode(const OutputChannelMode &outputChannelMode)
zypp::Pathname workingDirectory() const
void setDieWithParent(bool enabled)
SignalProxy< void()> sigFailedToStart()
SignalProxy< void(int)> sigFinished()
Environment environment() const
const std::string & execError() const
Namespace intended to collect all environment variables we use.
AutoDispose<int> calling ::close
static std::optional< Pipe > create(int flags=0)
#define ZYPP_IMPL_PRIVATE(Class)