diff options
Diffstat (limited to 'src/ProcessManager.hpp')
| -rw-r--r-- | src/ProcessManager.hpp | 75 |
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 |
