|
@@ -68,8 +68,7 @@ void QMLHandler::reopenCLI(QString ip) {
|
|
|
|
|
|
close(outpipefd[0]);
|
|
|
close(inpipefd[1]);
|
|
|
-
|
|
|
- std::thread(&QMLHandler::readPipeLoop, this).detach();
|
|
|
+ std::thread(&QMLHandler::readPipeLoop, this, pid).detach();
|
|
|
}
|
|
|
|
|
|
std::vector<std::string> tokenizeByNewlines(std::string in) {
|
|
@@ -212,7 +211,7 @@ void QMLHandler::handleJSON(string buffer) {
|
|
|
// If will read the Input Pipe, which containts the string that get printed
|
|
|
// on stdout by the CLI/Server, and calls handleJSON with the read content
|
|
|
// one it reads a newline.
|
|
|
-void QMLHandler::readPipeLoop() {
|
|
|
+void QMLHandler::readPipeLoop(pid_t childid) {
|
|
|
unsigned int readOffset = 0;
|
|
|
unsigned int pollCount = 0;
|
|
|
struct pollfd inPipeStatus;
|
|
@@ -245,6 +244,11 @@ void QMLHandler::readPipeLoop() {
|
|
|
memset(buf, 0, 1025);
|
|
|
pollCount = 0;
|
|
|
readOffset = 0;
|
|
|
+ if (waitpid(childid, NULL, WNOHANG)) {
|
|
|
+ // nonzero means error or childid has changed state
|
|
|
+ // for us that means child has exited -> CLI is dead
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Fixme
|