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

libzypp 17.38.6

process.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14
15#ifndef ZYPPNG_IO_PROCESS_H_DEFINED
16#define ZYPPNG_IO_PROCESS_H_DEFINED
17
18#include <zypp-core/ng/io/AsyncDataSource>
19#include <zypp-core/ng/base/Signals>
20#include <memory>
21#include <map>
22#include <signal.h>
23
24namespace zyppng {
25
26 class ProcessPrivate;
27 class IODevice;
28
29 ZYPP_FWD_DECL_TYPE_WITH_REFS (Process);
30
31 class Process : public AsyncDataSource
32 {
33 ZYPP_DECLARE_PRIVATE(Process)
34 public:
38 using Environment = std::map<std::string,std::string>;
39 using Ptr = ProcessRef;
40 using WeakPtr = ProcessWeakRef;
41
42 enum OutputChannelMode {
43 Seperate,
44 Merged
45 };
46
47 enum OutputChannel {
48 StdOut = 0,
49 StdErr = 1
50 };
51
52 static Ptr create ();
53 ~Process() override;
54
55 bool start ( const char *const *argv );
56 void stop ( int signal = SIGTERM );
57 bool isRunning ();
58 void close () override;
59
65 void waitForExit ();
66
71 void closeWriteChannel () override;
72
73 const std::string &executedCommand () const;
74 const std::string &execError() const;
75
76 zypp::Pathname chroot() const;
77 void setChroot( const zypp::Pathname &chroot );
78
79 bool useDefaultLocale() const;
80 void setUseDefaultLocale( bool defaultLocale );
81
82 Environment environment() const;
83 void setEnvironment( const Environment &environment );
84
85 pid_t pid ();
86 int exitStatus () const;
87
88 bool dieWithParent() const;
89 void setDieWithParent(bool enabled );
90
91 bool switchPgid() const;
92 void setSwitchPgid(bool enabled);
93
94 zypp::Pathname workingDirectory() const;
95 void setWorkingDirectory(const zypp::Pathname &workingDirectory);
96
97 const std::vector<int> &fdsToMap () const;
98 void addFd ( int fd );
99
100 int stdinFd ();
101 int stdoutFd ();
102 int stderrFd ();
103
104 SignalProxy<void ()> sigStarted ();
105 SignalProxy<void ()> sigFailedToStart ();
106 SignalProxy<void ( int )> sigFinished ();
107
108 OutputChannelMode outputChannelMode() const;
109 void setOutputChannelMode(const OutputChannelMode &outputChannelMode);
110
111 protected:
112 Process();
113 };
114}
115
116#endif // ZYPPNG_IO_PROCESS_H_DEFINED
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zyppng::AsyncDataSource::AsyncDataSource
AsyncDataSource()
Definition asyncdatasource.cpp:139
zyppng::IODevice
Definition iodevice.h:33
zyppng::ProcessPrivate
Definition process.cpp:17
zyppng::Process
Definition process.h:32
zyppng::Process::switchPgid
bool switchPgid() const
Definition process.cpp:239
zyppng::Process::outputChannelMode
OutputChannelMode outputChannelMode() const
Definition process.cpp:299
zyppng::Process::Environment
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
Definition process.h:38
zyppng::Process::chroot
zypp::Pathname chroot() const
Definition process.cpp:189
zyppng::Process::~Process
~Process() override
Definition process.cpp:54
zyppng::Process::dieWithParent
bool dieWithParent() const
Definition process.cpp:229
zyppng::Process::close
void close() override
Definition process.cpp:153
zyppng::Process::exitStatus
int exitStatus() const
Definition process.cpp:224
zyppng::Process::Process
Process()
Definition process.cpp:44
zyppng::Process::setEnvironment
void setEnvironment(const Environment &environment)
Definition process.cpp:214
zyppng::Process::stop
void stop(int signal=SIGTERM)
Definition process.cpp:139
zyppng::Process::closeWriteChannel
void closeWriteChannel() override
Definition process.cpp:172
zyppng::Process::executedCommand
const std::string & executedCommand() const
Definition process.cpp:179
zyppng::Process::addFd
void addFd(int fd)
Definition process.cpp:264
zyppng::Process::OutputChannelMode
OutputChannelMode
Definition process.h:42
zyppng::Process::Seperate
@ Seperate
Definition process.h:43
zyppng::Process::Merged
@ Merged
Definition process.h:44
zyppng::Process::create
static Ptr create()
Definition process.cpp:49
zyppng::Process::start
bool start(const char *const *argv)
Definition process.cpp:63
zyppng::Process::isRunning
bool isRunning()
Definition process.cpp:147
zyppng::Process::useDefaultLocale
bool useDefaultLocale() const
Definition process.cpp:199
zyppng::Process::waitForExit
void waitForExit()
Definition process.cpp:161
zyppng::Process::setWorkingDirectory
void setWorkingDirectory(const zypp::Pathname &workingDirectory)
Definition process.cpp:254
zyppng::Process::sigStarted
SignalProxy< void()> sigStarted()
Definition process.cpp:284
zyppng::Process::Ptr
ProcessRef Ptr
Definition process.h:39
zyppng::Process::stderrFd
int stderrFd()
Definition process.cpp:279
zyppng::Process::fdsToMap
const std::vector< int > & fdsToMap() const
Definition process.cpp:259
zyppng::Process::WeakPtr
ProcessWeakRef WeakPtr
Definition process.h:40
zyppng::Process::setUseDefaultLocale
void setUseDefaultLocale(bool defaultLocale)
Definition process.cpp:204
zyppng::Process::setSwitchPgid
void setSwitchPgid(bool enabled)
Definition process.cpp:244
zyppng::Process::stdinFd
int stdinFd()
Definition process.cpp:269
zyppng::Process::pid
pid_t pid()
Definition process.cpp:219
zyppng::Process::setChroot
void setChroot(const zypp::Pathname &chroot)
Definition process.cpp:194
zyppng::Process::setOutputChannelMode
void setOutputChannelMode(const OutputChannelMode &outputChannelMode)
Definition process.cpp:300
zyppng::Process::OutputChannel
OutputChannel
Definition process.h:47
zyppng::Process::StdErr
@ StdErr
Definition process.h:49
zyppng::Process::StdOut
@ StdOut
Definition process.h:48
zyppng::Process::stdoutFd
int stdoutFd()
Definition process.cpp:274
zyppng::Process::workingDirectory
zypp::Pathname workingDirectory() const
Definition process.cpp:249
zyppng::Process::setDieWithParent
void setDieWithParent(bool enabled)
Definition process.cpp:234
zyppng::Process::sigFailedToStart
SignalProxy< void()> sigFailedToStart()
Definition process.cpp:289
zyppng::Process::sigFinished
SignalProxy< void(int)> sigFinished()
Definition process.cpp:294
zyppng::Process::environment
Environment environment() const
Definition process.cpp:209
zyppng::Process::execError
const std::string & execError() const
Definition process.cpp:184
zyppng::SignalProxy
Definition signals.h:325
zyppng
Definition MediaNetworkRequestExecutor.h:16
ZYPP_DECLARE_PRIVATE
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:80
ZYPP_FWD_DECL_TYPE_WITH_REFS
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:119