From cc019e360b293a79495c20f670c40bb879cf05a0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 2 Apr 2021 16:10:47 +0100 Subject: [PATCH] apitest: Provide OtterPauseable etc. Signed-off-by: Ian Jackson --- apitest/apitest.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/apitest/apitest.rs b/apitest/apitest.rs index 58305f72..211ef5b5 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -765,23 +765,35 @@ impl DirSubst { // -------------------- concurrency management -------------------- +pub struct OtterPauseable(nix::unistd::Pid); pub struct OtterPaused(nix::unistd::Pid); impl SetupCore { + pub fn otter_pauseable(&self) -> OtterPauseable { + OtterPauseable(nix::unistd::Pid::from_raw( + self.server_child.id() as nix::libc::pid_t + )) + } + #[throws(AE)] pub fn pause_otter(&self) -> OtterPaused { - let pid = nix::unistd::Pid::from_raw( - self.server_child.id() as nix::libc::pid_t - ); - nix::sys::signal::kill(pid, nix::sys::signal::SIGSTOP)?; - OtterPaused(pid) + self.otter_pauseable().pause()? + } +} + +impl OtterPauseable { + #[throws(AE)] + pub fn pause(self) -> OtterPaused { + nix::sys::signal::kill(self.0, nix::sys::signal::SIGSTOP)?; + OtterPaused(self.0) } } impl OtterPaused { #[throws(AE)] - pub fn resume(self) { + pub fn resume(self) -> OtterPauseable { nix::sys::signal::kill(self.0, nix::sys::signal::SIGCONT)?; + OtterPauseable(self.0) } } -- 2.30.2