diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77904d2..0ef0f22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,7 +102,7 @@ add_custom_command( set (PIPEDAL_SOURCES - StdOutCapture.hpp StdOutCapture.cpp + StdErrorCapture.hpp StdErrorCapture.cpp Ipv6Helpers.cpp Ipv6Helpers.hpp PluginPreset.cpp PluginPreset.hpp CpuGovernor.cpp CpuGovernor.hpp diff --git a/src/Lv2Host.cpp b/src/Lv2Host.cpp index 69f62d9..68d5f62 100644 --- a/src/Lv2Host.cpp +++ b/src/Lv2Host.cpp @@ -41,7 +41,7 @@ #include "lv2/lv2plug.in/ns/ext/port-groups/port-groups.h" #include #include "PiPedalException.hpp" -#include "StdOutCapture.hpp" +#include "StdErrorCapture.hpp" #include "Locale.hpp" @@ -391,7 +391,7 @@ void Lv2Host::Load(const char *lv2Path) free_world(); setenv("LV2_PATH", lv2Path, true); - StdOutCapture stdoutCapture; // captures lilv messages written to STDOUT. + StdErrorCapture stdoutCapture; // captures lilv messages written to STDOUT. pWorld = lilv_world_new(); { diff --git a/src/StdOutCapture.cpp b/src/StdErrorCapture.cpp similarity index 87% rename from src/StdOutCapture.cpp rename to src/StdErrorCapture.cpp index c27be3a..66d8c95 100644 --- a/src/StdOutCapture.cpp +++ b/src/StdErrorCapture.cpp @@ -18,7 +18,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#include "StdOutCapture.hpp" +#include "StdErrorCapture.hpp" #include #include #include @@ -38,18 +38,19 @@ using namespace pipedal; constexpr int STDOUT_HANDLE = 2; -StdOutCapture::StdOutCapture() +StdErrorCapture::StdErrorCapture() { - this->tempFileName = std::tmpnam(nullptr); + char filename[] = "/tmp/pipedal.XXXXXX"; + int redirectHandle = mkstemp(filename); + this->tempFileName = filename; - int redirectHandle = open(tempFileName.c_str(),O_CREAT | O_WRONLY | O_TRUNC); this->oldStdout = dup(STDOUT_HANDLE); dup2(redirectHandle,STDOUT_HANDLE); close(redirectHandle); } -StdOutCapture::~StdOutCapture() +StdErrorCapture::~StdErrorCapture() { EndCapture(); if (tempFileName.length() != 0) @@ -58,7 +59,7 @@ StdOutCapture::~StdOutCapture() } } -void StdOutCapture::EndCapture() +void StdErrorCapture::EndCapture() { if (this->oldStdout != -1) @@ -70,7 +71,7 @@ void StdOutCapture::EndCapture() } } -std::vector StdOutCapture::GetOutputLines() { +std::vector StdErrorCapture::GetOutputLines() { EndCapture(); std::vector result; diff --git a/src/StdOutCapture.hpp b/src/StdErrorCapture.hpp similarity index 93% rename from src/StdOutCapture.hpp rename to src/StdErrorCapture.hpp index ed8c5c7..72de8b4 100644 --- a/src/StdOutCapture.hpp +++ b/src/StdErrorCapture.hpp @@ -20,13 +20,14 @@ #pragma once #include +#include namespace pipedal { -class StdOutCapture { +class StdErrorCapture { public: - StdOutCapture(); - ~StdOutCapture(); + StdErrorCapture(); + ~StdErrorCapture(); void EndCapture();