|
a/src/utils/execmd.h |
|
b/src/utils/execmd.h |
|
... |
|
... |
33 |
* Callback function object to advise of new data arrival, or just periodic
|
33 |
* Callback function object to advise of new data arrival, or just periodic
|
34 |
* heartbeat if cnt is 0.
|
34 |
* heartbeat if cnt is 0.
|
35 |
*
|
35 |
*
|
36 |
* To interrupt the command, the code using ExecCmd should either
|
36 |
* To interrupt the command, the code using ExecCmd should either
|
37 |
* raise an exception inside newData() (and catch it in doexec's caller), or
|
37 |
* raise an exception inside newData() (and catch it in doexec's caller), or
|
38 |
* call ExecCmd::setCancel()
|
38 |
* call ExecCmd::setKill()
|
39 |
*
|
39 |
*
|
40 |
*/
|
40 |
*/
|
41 |
class ExecCmdAdvise {
|
41 |
class ExecCmdAdvise {
|
42 |
public:
|
42 |
public:
|
43 |
virtual ~ExecCmdAdvise() {}
|
43 |
virtual ~ExecCmdAdvise() {}
|
|
... |
|
... |
143 |
/**
|
143 |
/**
|
144 |
* Cancel/kill command. This can be called from another thread or
|
144 |
* Cancel/kill command. This can be called from another thread or
|
145 |
* from the advise callback, which could also raise an exception to
|
145 |
* from the advise callback, which could also raise an exception to
|
146 |
* accomplish the same thing
|
146 |
* accomplish the same thing
|
147 |
*/
|
147 |
*/
|
148 |
void setCancel() {m_cancelRequest = true;}
|
148 |
void setKill() {m_killRequest = true;}
|
149 |
|
149 |
|
150 |
ExecCmd()
|
150 |
ExecCmd()
|
151 |
: m_advise(0), m_provide(0), m_timeoutMs(1000)
|
151 |
: m_advise(0), m_provide(0), m_timeoutMs(1000)
|
152 |
{
|
152 |
{
|
153 |
reset();
|
153 |
reset();
|
|
... |
|
... |
167 |
friend class ExecCmdRsrc;
|
167 |
friend class ExecCmdRsrc;
|
168 |
private:
|
168 |
private:
|
169 |
vector<string> m_env;
|
169 |
vector<string> m_env;
|
170 |
ExecCmdAdvise *m_advise;
|
170 |
ExecCmdAdvise *m_advise;
|
171 |
ExecCmdProvide *m_provide;
|
171 |
ExecCmdProvide *m_provide;
|
172 |
bool m_cancelRequest;
|
172 |
bool m_killRequest;
|
173 |
int m_timeoutMs;
|
173 |
int m_timeoutMs;
|
174 |
string m_stderrFile;
|
174 |
string m_stderrFile;
|
175 |
// Pipe for data going to the command
|
175 |
// Pipe for data going to the command
|
176 |
int m_pipein[2];
|
176 |
int m_pipein[2];
|
177 |
NetconP m_tocmd;
|
177 |
NetconP m_tocmd;
|
|
... |
|
... |
184 |
sigset_t m_blkcld;
|
184 |
sigset_t m_blkcld;
|
185 |
|
185 |
|
186 |
// Reset internal state indicators. Any resources should have been
|
186 |
// Reset internal state indicators. Any resources should have been
|
187 |
// previously freed
|
187 |
// previously freed
|
188 |
void reset() {
|
188 |
void reset() {
|
189 |
m_cancelRequest = false;
|
189 |
m_killRequest = false;
|
190 |
m_pipein[0] = m_pipein[1] = m_pipeout[0] = m_pipeout[1] = -1;
|
190 |
m_pipein[0] = m_pipein[1] = m_pipeout[0] = m_pipeout[1] = -1;
|
191 |
m_pid = -1;
|
191 |
m_pid = -1;
|
192 |
sigemptyset(&m_blkcld);
|
192 |
sigemptyset(&m_blkcld);
|
193 |
}
|
193 |
}
|
194 |
// Child process code
|
194 |
// Child process code
|