diff --git a/src/c++wrap.hh b/src/c++wrap.hh index 4de83aa7..6b93c1a6 100644 --- a/src/c++wrap.hh +++ b/src/c++wrap.hh @@ -24,7 +24,7 @@ #ifndef CPPWRAP_HH #define CPPWRAP_HH -#include +#include #include #include diff --git a/src/update-cb.cc b/src/update-cb.cc index b2f9009f..985c8452 100644 --- a/src/update-cb.cc +++ b/src/update-cb.cc @@ -39,9 +39,15 @@ namespace conky { if(thread) { done = true; sem_start.post(); + if(pipefd.second >= 0) + write(pipefd.second, "X", 1); thread->join(); delete thread; } + if(pipefd.first >= 0) + close(pipefd.first); + if(pipefd.second >= 0) + close(pipefd.second); } inline size_t callback_base::get_hash(const handle &h) diff --git a/src/update-cb.hh b/src/update-cb.hh index 83e72554..2bc8df4d 100644 --- a/src/update-cb.hh +++ b/src/update-cb.hh @@ -32,6 +32,7 @@ #include +#include "c++wrap.hh" #include "semaphore.hh" namespace conky { @@ -55,6 +56,7 @@ namespace conky { const size_t hash; uint32_t period; uint32_t remaining; + std::pair pipefd; const bool wait; bool done; uint8_t unused; @@ -83,11 +85,15 @@ namespace conky { friend void conky::run_all_callbacks(); protected: - callback_base(size_t hash_, uint32_t period_, bool wait_) - : thread(NULL), hash(hash_), period(period_), remaining(0), wait(wait_), - done(false), unused(0) + callback_base(size_t hash_, uint32_t period_, bool wait_, bool use_pipe = false) + : thread(NULL), hash(hash_), period(period_), remaining(0), + pipefd(use_pipe ? pipe2(O_CLOEXEC) : std::pair(-1, -1)), + wait(wait_), done(false), unused(0) {} + int donefd() + { return pipefd.first; } + // to be implemented by descendant classes virtual void work() = 0;