diff --git a/include/util/command.hpp b/include/util/command.hpp index ca10718b..69b1fd46 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -33,7 +33,7 @@ inline int close(FILE* fp, pid_t pid) { fclose(fp); while (waitpid(pid, &stat, 0) == -1) { if (errno != EINTR) { - stat = -1; + stat = 0; break; } } diff --git a/include/util/sleeper_thread.hpp b/include/util/sleeper_thread.hpp index 90ef9d89..642d47d4 100644 --- a/include/util/sleeper_thread.hpp +++ b/include/util/sleeper_thread.hpp @@ -14,7 +14,10 @@ class SleeperThread { SleeperThread(std::function func) : thread_{[this, func] { - while (do_run_) func(); + while (do_run_) { + signal_ = false; + func(); + } }} {} SleeperThread& operator=(std::function func) { @@ -42,7 +45,10 @@ class SleeperThread { } auto wake_up() { - signal_ = true; + { + std::lock_guard lck(mutex_); + signal_ = true; + } condvar_.notify_all(); }