fix(custom): failed getline after closed pipe

This commit is contained in:
Alexis 2018-12-08 13:57:56 +01:00
parent 1b13f9e38c
commit 0acc50264e
1 changed files with 4 additions and 2 deletions

View File

@ -54,8 +54,10 @@ void waybar::modules::Custom::continuousWorker()
char* buff = nullptr; char* buff = nullptr;
size_t len = 0; size_t len = 0;
if (getline(&buff, &len, fp_) == -1) { if (getline(&buff, &len, fp_) == -1) {
if (fp_) {
pclose(fp_); pclose(fp_);
fp_ = nullptr; fp_ = nullptr;
}
thread_.stop(); thread_.stop();
output_ = { 1, "" }; output_ = { 1, "" };
std::cerr << name_ + " just stopped, is it endless?" << std::endl; std::cerr << name_ + " just stopped, is it endless?" << std::endl;