27#if __has_include(<boost/process/v1.hpp>)
28#include <boost/process/v1.hpp>
29namespace bp = boost::process::v1;
31#include <boost/process.hpp>
32namespace bp = boost::process;
113 bp::child c(runCommand, bp::std_in < in, bp::std_out > out, bp::std_err > err);
115 std::thread outReaderThread([&out,
this]() {
118 while (std::getline(out, buffer)) {
120 if (!buffer.empty() && (buffer.back() ==
'\r')) {
128 std::thread errReaderThread([&err,
this]() {
131 while (std::getline(err, buffer)) {
133 if (!buffer.empty() && (buffer.back() ==
'\r')) {
144 if (outReaderThread.joinable()) {
145 outReaderThread.join();
147 if (errReaderThread.joinable()) {
148 errReaderThread.join();
156 return c.exit_code();
168 for (
int i = 0; i < 128; i++) {
175 myPipe = popen((runCommand +
" 2>&1").c_str(),
"r");
192 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