diff --git a/include/AModule.hpp b/include/AModule.hpp index 2ffc429c..2fcbfc23 100644 --- a/include/AModule.hpp +++ b/include/AModule.hpp @@ -36,6 +36,7 @@ class AModule : public IModule { SCROLL_DIR getScrollDir(GdkEventScroll *e); bool tooltipEnabled() const; + std::vector pid_children_; const std::string name_; const Json::Value &config_; Gtk::EventBox event_box_; @@ -54,7 +55,6 @@ class AModule : public IModule { const bool isTooltip; const bool isExpand; bool hasUserEvents_; - std::vector pid_; gdouble distance_scrolled_y_; gdouble distance_scrolled_x_; std::map eventActionMap_; diff --git a/src/AModule.cpp b/src/AModule.cpp index 7de1ad9a..259c6a39 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -83,7 +83,7 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: } AModule::~AModule() { - for (const auto& pid : pid_) { + for (const auto& pid : pid_children_) { if (pid != -1) { killpg(pid, SIGTERM); } @@ -93,7 +93,7 @@ AModule::~AModule() { auto AModule::update() -> void { // Run user-provided update handler if configured if (config_["on-update"].isString()) { - pid_.push_back(util::command::forkExec(config_["on-update"].asString())); + pid_children_.push_back(util::command::forkExec(config_["on-update"].asString())); } } // Get mapping between event name and module action name @@ -182,7 +182,7 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) { format.clear(); } if (!format.empty()) { - pid_.push_back(util::command::forkExec(format)); + pid_children_.push_back(util::command::forkExec(format)); } dp.emit(); return true; @@ -267,7 +267,7 @@ bool AModule::handleScroll(GdkEventScroll* e) { this->AModule::doAction(eventName); // Second call user scripts if (config_[eventName].isString()) - pid_.push_back(util::command::forkExec(config_[eventName].asString())); + pid_children_.push_back(util::command::forkExec(config_[eventName].asString())); dp.emit(); return true; diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 052247e0..0220e348 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -35,6 +35,13 @@ waybar::modules::Custom::~Custom() { void waybar::modules::Custom::delayWorker() { thread_ = [this] { + for (int i: this->pid_children_) { + int status; + waitpid(i, &status, 0); + } + + this->pid_children_.clear(); + bool can_update = true; if (config_["exec-if"].isString()) { output_ = util::command::execNoRead(config_["exec-if"].asString());