From 3a4d56589efd125ddf252af617cca511fe806254 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 26 May 2015 21:23:49 +0200 Subject: [PATCH] properly terminate guile thread --- src/bindings/Guile.cxx | 7 ++++++- src/bindings/Guile.hxx | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) 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_ */ -- 2.39.5