|
@@ -1,11 +1,51 @@
|
|
|
#include <QGuiApplication>
|
|
|
#include <QObject>
|
|
|
#include <QQmlApplicationEngine>
|
|
|
+#include <csignal>
|
|
|
+#include <cstdio>
|
|
|
+#include <cstdlib>
|
|
|
+#include <cstring>
|
|
|
#include <iostream>
|
|
|
+#include <sys/prctl.h>
|
|
|
+#include <sys/wait.h>
|
|
|
+#include <unistd.h>
|
|
|
|
|
|
#include "qmlhandler.h"
|
|
|
|
|
|
+using namespace std;
|
|
|
+int inpipefd[2];
|
|
|
+int outpipefd[2];
|
|
|
+char buf[1024];
|
|
|
+
|
|
|
int main(int argc, char *argv[]) {
|
|
|
+ pid_t pid = 0;
|
|
|
+ char msg[256];
|
|
|
+ int status;
|
|
|
+
|
|
|
+ pipe(inpipefd);
|
|
|
+ pipe(outpipefd);
|
|
|
+ pid = fork();
|
|
|
+ if (pid == 0) {
|
|
|
+ // Child
|
|
|
+ dup2(outpipefd[0], STDIN_FILENO);
|
|
|
+ dup2(inpipefd[1], STDOUT_FILENO);
|
|
|
+ dup2(inpipefd[1], STDERR_FILENO);
|
|
|
+
|
|
|
+ // ask kernel to deliver SIGTERM in case the parent dies
|
|
|
+ prctl(PR_SET_PDEATHSIG, SIGTERM);
|
|
|
+
|
|
|
+ // replace tee with your process
|
|
|
+ execl("../../cli/ccats-cli", "h", (char *)NULL);
|
|
|
+ // Nothing below this line should be executed by child process. If so,
|
|
|
+ // it means that the execl function wasn't successfull, so lets exit:
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ close(outpipefd[0]);
|
|
|
+ close(inpipefd[1]);
|
|
|
+
|
|
|
+ // ########## GUI CODE; DO NOT TOUCH ##########
|
|
|
+
|
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
|
|
QGuiApplication app(argc, argv);
|
|
@@ -31,4 +71,6 @@ int main(int argc, char *argv[]) {
|
|
|
SLOT(setStatusMessage(QVariant)));
|
|
|
|
|
|
return app.exec();
|
|
|
+
|
|
|
+ // ########## GUI CODE; DO NOT TOUCH ##########
|
|
|
}
|