summaryrefslogtreecommitdiffstats
path: root/src/ProcessManager.hpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-09-09 19:00:56 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2015-09-09 19:02:23 +0200
commit8a6d4b06f2291c363f3dea17837ed20893852453 (patch)
treec091375499e35eaa1810586454e0834c06e6c9b2 /src/ProcessManager.hpp
parentf554a27046f203e56a07baaf214d90834942e3f5 (diff)
downloadmanager-8a6d4b06f2291c363f3dea17837ed20893852453.tar.gz
manager-8a6d4b06f2291c363f3dea17837ed20893852453.zip
Cleanup repo with some directories
Diffstat (limited to 'src/ProcessManager.hpp')
-rw-r--r--src/ProcessManager.hpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/ProcessManager.hpp b/src/ProcessManager.hpp
new file mode 100644
index 0000000..7782cb3
--- /dev/null
+++ b/src/ProcessManager.hpp
@@ -0,0 +1,75 @@
+#ifndef PROCESSMANAGER_HPP
+#define PROCESSMANAGER_HPP
+
+#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();
+};
+
+#endif // PROCESSMANAGER_HPP