blob: 2d64168cc4666e1f42015b0d189e16439230aece (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#pragma once
#define DELETE_SAVE(x) if(x != 0) \
{\
delete x;\
x = 0;\
}
#include <QObject>
#include <QFile>
#include <QSocketNotifier>
class ProcessManager : public QObject
{
Q_OBJECT
public:
explicit ProcessManager(const QString& prefix, const QString& id = "", bool useStdErr = false, QObject *parent = 0);
~ProcessManager();
bool isOk();
bool isRunning();
bool start(const QString& program, QStringList args);
QByteArray readAll();
QByteArray readLine();
qint64 write(const QByteArray& data);
bool isWritable();
bool setWorkingDirectory(const QString& path);
void kill();
void exit();
void closeProgFifos();
QString ID();
signals:
void readyRead();
void stdErrReadyRead();
void finished(int);
public slots:
private slots:
void ctrlOutReadyRead();
void _stdOutReadyRead();
void _stdErrReadyRead();
private:
QString prefix;
QString id;
QFile ctrlIn;
QFile ctrlOut;
QFile stdIn;
QFile stdOut;
QFile stdErr;
QSocketNotifier* ctrlOutNotifier = 0;
QSocketNotifier* stdOutNotifier = 0;
QSocketNotifier* stdErrNotifier = 0;
bool useStdErr = false;
bool ok = false;
bool running = false;
int pid = 0;
int exitCode = 0;
bool connectToIO();
void processCtrlMessage(const QString& message);
};
|