From 0c9edb0c4b79be195a090df8b2e78ca3f4f2fbc3 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 16 Feb 2019 09:48:27 +0100 Subject: [PATCH] fix(custom): check exist_status in endless script before clean the output --- src/modules/custom.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index c75760d..3c03777 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -53,14 +53,17 @@ void waybar::modules::Custom::continuousWorker() char* buff = nullptr; size_t len = 0; if (getline(&buff, &len, fp_) == -1) { + int exit_code = 1; if (fp_) { - pclose(fp_); + exit_code = WEXITSTATUS(pclose(fp_)); fp_ = nullptr; } thread_.stop(); - output_ = { 1, "" }; - std::cerr << name_ + " just stopped, is it endless?" << std::endl; - dp.emit(); + if (exit_code != 0) { + output_ = { exit_code, "" }; + dp.emit(); + std::cerr << name_ + " just stopped unexpectedly, is it endless?" << std::endl; + } return; }