From 564fdcb3693786234608a0fab7063ccba5388e10 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 11 Jun 2019 22:09:47 +0200 Subject: [PATCH] fix(custom): exit status --- include/util/command.hpp | 2 +- include/util/sleeper_thread.hpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/util/command.hpp b/include/util/command.hpp index ca10718..69b1fd4 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 90ef9d8..642d47d 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(); }