From 82e2a070e0d2a617cb47c285e176a3fff3ca64e8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Oct 2016 15:49:37 +0200 Subject: Add some functions needed by hydra --- src/libutil/sync.hh | 8 ++++++++ src/libutil/util.cc | 8 ++++++++ src/libutil/util.hh | 1 + 3 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/libutil/sync.hh b/src/libutil/sync.hh index ebe64ffbd..2aa074299 100644 --- a/src/libutil/sync.hh +++ b/src/libutil/sync.hh @@ -54,6 +54,14 @@ public: cv.wait(lk); } + template + void wait_for(std::condition_variable & cv, + const std::chrono::duration & duration) + { + assert(s); + cv.wait_for(lk, duration); + } + template bool wait_for(std::condition_variable & cv, const std::chrono::duration & duration, diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 1f923fe6b..ce16cc30a 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -778,6 +778,14 @@ void Pid::setKillSignal(int signal) } +pid_t Pid::release() +{ + pid_t p = pid; + pid = -1; + return p; +} + + void killUser(uid_t uid) { debug(format("killing all processes running under uid ‘%1%’") % uid); diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 259c73260..50b96f7ed 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -220,6 +220,7 @@ public: int wait(bool block); void setSeparatePG(bool separatePG); void setKillSignal(int signal); + pid_t release(); }; -- cgit v1.2.3