From a8a699133e14507e360d93603f685878a9cec1fd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 9 Nov 2019 06:28:55 +0100 Subject: [PATCH] Fix child-process communication (video monitor in particular) 103ef2ba08e5 introduced an API to write raw data (const void*) to a child process, along with the previous API to write (std::string const&) VideoMonitor uses write_to_stdin("fixed text"), and g++ interprets this to use the (const void*) API instead of the std::string, which breaks communication. --- libs/pbd/pbd/system_exec.h | 8 ++++++++ libs/pbd/system_exec.cc | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/libs/pbd/pbd/system_exec.h b/libs/pbd/pbd/system_exec.h index 9247323786..1d7e631f54 100644 --- a/libs/pbd/pbd/system_exec.h +++ b/libs/pbd/pbd/system_exec.h @@ -180,6 +180,14 @@ class LIBPBD_API SystemExec */ size_t write_to_stdin (std::string const& d, size_t len=0); + /** write into child-program's STDIN + * @param d text to write + * @param len length of data to write, if it is 0 (zero), d.length() is + * used to determine the number of bytes to transmit. + * @return number of bytes written. + */ + size_t write_to_stdin (const char* d, size_t len=0); + /** write into child-program's STDIN * @param data data to write * @param bytes length of data to write diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc index 7e24e8d1b3..56eba6959e 100644 --- a/libs/pbd/system_exec.cc +++ b/libs/pbd/system_exec.cc @@ -401,6 +401,15 @@ SystemExec::write_to_stdin (std::string const& d, size_t len) return write_to_stdin ((const void*)data, len); } +size_t +SystemExec::write_to_stdin (const char* data, size_t len) +{ + if (len == 0) { + len = strlen (data); + } + return write_to_stdin ((const void*)data, len); +} + #ifdef PLATFORM_WINDOWS /* Windows Process */ /* HELPER FUNCTIONS */