25#pragma warning(push, 0)
26#define WIN32_LEAN_AND_MEAN
29#include <boost/process.hpp>
30#include <boost/process/v1/child.hpp>
31#include <boost/process/v1/io.hpp>
34#pragma GCC diagnostic push
35#pragma GCC diagnostic ignored "-Wall"
36#pragma GCC diagnostic ignored "-Wextra"
37#include <boost/process.hpp>
38#include <boost/process/v1/child.hpp>
39#include <boost/process/v1/io.hpp>
40#pragma GCC diagnostic pop
110 boost::process::v1::opstream in;
111 boost::process::v1::ipstream out;
112 boost::process::v1::ipstream err;
121 boost::process::v1::child c(runCommand,
122 boost::process::v1::std_in < in,
123 boost::process::v1::std_out > out,
124 boost::process::v1::std_err > err);
126 std::thread outReaderThread([&out,
this]() {
129 while (std::getline(out, buffer)) {
131 if (!buffer.empty() && (buffer.back() ==
'\r')) {
139 std::thread errReaderThread([&err,
this]() {
142 while (std::getline(err, buffer)) {
144 if (!buffer.empty() && (buffer.back() ==
'\r')) {
155 if (outReaderThread.joinable()) {
156 outReaderThread.join();
158 if (errReaderThread.joinable()) {
159 errReaderThread.join();
167 return c.exit_code();
179 for (
int i = 0; i < 128; i++) {
186 myPipe = popen((runCommand +
" 2>&1").c_str(),
"r");
203 while (fgets(buffer,
sizeof buffer,
myPipe) != NULL) {
@ MESSAGE_OCCURRED
send when a message occurred
@ ERROR_OCCURRED
send when a error occurred
@ OUTPUT_OCCURRED
send when a tool produces output
@ TOOL_ENDED
send when a tool finishes
@ WARNING_OCCURRED
send when a warning occurred
void setExternalRunner(GNEExternalRunner *externalRunner)
set external runner
bool myErrorOccurred
flag for check if during execution an error was Occurred
~GNEExternalRunner()
destructor
GNERunDialog * myRunDialog
pointer to current run dialog
bool errorOccurred() const
check if during execution an error was Occurred
GNEExternalRunner(GNEApplicationWindow *applicationWindow)
Constructor.
bool isRunning() const
check if is running
void runTool(GNERunDialog *runDialog)
run tool called from dialog
void abort()
abort running
FXint run()
starts the thread. The thread ends after the tool is finished
bool myRunning
flag for check if we have a running process
void addEvent(GUIEvent *event, const bool signal)
add event in the queue
virtual std::string getRunCommand() const =0
get run command
static std::string transcodeToLocal(const std::string &utf8String)
convert a string from UTF-8 to the local codepage