From: Christoph Egger Date: Tue, 26 May 2015 19:23:49 +0000 (+0200) Subject: properly terminate guile thread X-Git-Tag: v0.2^0 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=3a4d56589efd125ddf252af617cca511fe806254;p=frida%2Ffrida.git properly terminate guile thread --- diff --git a/src/bindings/Guile.cxx b/src/bindings/Guile.cxx index 18d12e9..aa7ea52 100644 --- a/src/bindings/Guile.cxx +++ b/src/bindings/Guile.cxx @@ -15,7 +15,7 @@ GuileInterpreter::GuileInterpreter() scm_init_guile(); scm_c_use_module("system repl server"); - guile::Geiser* geiser = new guile::Geiser(this); + geiser = new guile::Geiser(this); geiser->start(); scm_c_load_extension("libguile-frida-binding", @@ -28,6 +28,11 @@ GuileInterpreter::GuileInterpreter() LOG4CXX_INFO(logger, "Initializing GUILE finished"); } +GuileInterpreter::~GuileInterpreter() { + geiser->terminate(); + geiser->wait(); +} + int GuileInterpreter::evaluateWithErrorHandling(SCM (*fun)(void *), void* data, std::ostream& stdout, diff --git a/src/bindings/Guile.hxx b/src/bindings/Guile.hxx index 244bb1c..63d5fcb 100644 --- a/src/bindings/Guile.hxx +++ b/src/bindings/Guile.hxx @@ -7,12 +7,24 @@ #include "qt.hxx" #include "Interpreter.hxx" +namespace guile { + class Geiser : public QThread { + Q_OBJECT + public: + Geiser(QObject* parent) : QThread(parent) {} + Geiser() {} + private: + void run() Q_DECL_OVERRIDE; + }; +} + class GuileInterpreter : public QObject, public Interpreter { Q_OBJECT Q_PLUGIN_METADATA(IID "xyz.frida.Interpreter") Q_INTERFACES(Interpreter) public: GuileInterpreter(); + virtual ~GuileInterpreter(); int evaluate(const std::string& command, std::ostream& stdout, @@ -35,17 +47,7 @@ private: SCM guile_output_port; SCM guile_error_port; log4cxx::LoggerPtr logger; + guile::Geiser* geiser; }; -namespace guile { - class Geiser : public QThread { - Q_OBJECT - public: - Geiser(QObject* parent) : QThread(parent) {} - private: - void run() Q_DECL_OVERRIDE; - }; -} - - #endif /* INCLUDE__Guile_hxx_ */