From 82f8524b7fe59732f50a8f201e32d893ec9bf376 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Tue, 11 Jul 2023 23:23:45 +0200 Subject: Fix getting stuck when ProcessManager fifos aren’t open on the other end MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProcessManager.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ProcessManager.cpp b/src/ProcessManager.cpp index e34ebfc..09f725f 100644 --- a/src/ProcessManager.cpp +++ b/src/ProcessManager.cpp @@ -1,5 +1,7 @@ #include "ProcessManager.hpp" +#include #include +#include #include #include @@ -28,8 +30,23 @@ ProcessManager::ProcessManager(const QString &newPrefix, const QString &newId, b stdErr.setFileName(prefix + id + "stderr"); ctrlIn.setFileName(prefix + id + "ctrlin"); ctrlOut.setFileName(prefix + id + "ctrlout"); + + bool reattach = ctrlIn.exists(); + if(reattach) + { + int fd = open(ctrlIn.fileName().toLocal8Bit().toStdString().c_str(), O_WRONLY | O_NONBLOCK); + if(fd == -1) + { + reattach = false; + } + else + { + close(fd); + } + } + bool reattaching = false; - if(!ctrlIn.exists()) + if(!reattach) { if(!QProcess::startDetached("ProcessManager", QStringList() << prefix + id)) { -- cgit v1.2.3-54-g00ecf