30 #include <ArmarXCore/interface/components/ExternalApplicationManagerInterface.h>
33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Wunused-result"
35 #include <boost/asio.hpp>
36 #include <boost/iostreams/device/file_descriptor.hpp>
37 #include <boost/iostreams/stream.hpp>
40 #pragma GCC diagnostic pop
44 #if defined(BOOST_WINDOWS_API)
45 using pipe_end = boost::asio::windows::stream_handle;
46 #elif defined(BOOST_POSIX_API)
47 using pipe_end = boost::asio::posix::stream_descriptor;
81 virtual public armarx::ExternalApplicationManagerInterface
88 return "ExternalApplicationManager";
122 struct StreamMetaData
125 StreamMetaData(
const StreamMetaData&
data);
128 boost::asio::io_service io_service;
129 boost::process::pipe pipe;
131 boost::asio::streambuf input_buffer;
132 boost::iostreams::file_descriptor_sink sink;
133 std::function<void(
const boost::system::error_code& error, std::size_t size)>
read;
135 using StreamMetaDataPtr = std::shared_ptr<struct StreamMetaData>;
139 void updateLogSenderComponentName();
141 void startApplication();
142 void stopApplication();
143 void waitForApplication();
147 bool waitForProcessToFinish(
int pid,
int timeoutMS);
149 void setupStream(StreamMetaData& meta);
154 std::string application;
156 Ice::StringSeq envVars;
157 bool restartWhenCrash;
158 bool disconnectWhenCrash;
159 std::string startUpKeyword;
160 std::string workingDir;
161 bool redirectToArmarXLog;
163 std::unique_ptr<boost::process::child> childProcess;
166 bool appStoppedOnPurpose;
170 boost::iostreams::stream<boost::iostreams::file_descriptor_source> out_stream;
171 StreamMetaDataPtr outMetaData;
173 boost::iostreams::stream<boost::iostreams::file_descriptor_source> err_stream;
174 StreamMetaDataPtr errMetaData;
176 boost::iostreams::file_descriptor_source stdout_source;
177 boost::iostreams::file_descriptor_source stderr_source;
181 std::string starterUUID, depObjUUID;