pub struct SetupCore {
pub ds: DirSubst,
pub mgmt_conn: MgmtChannel,
- pub server_child: Child,
+ server_child: Child,
pub wanted_tests: TrackWantedTests,
}
}
}
+// -------------------- concurrency management --------------------
+
+pub struct OtterPaused(nix::unistd::Pid);
+
+impl SetupCore {
+ #[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)
+ }
+}
+
+impl OtterPaused {
+ #[throws(AE)]
+ pub fn resume(self) {
+ nix::sys::signal::kill(self.0, nix::sys::signal::SIGCONT)?;
+ }
+}
+
+impl Drop for OtterPaused {
+ fn drop(&mut self) {
+ debug!("note, otter server pid={} was still paused", self.0);
+ }
+}
+
// -------------------- utilities --------------------
#[ext(pub)]
dbg!(&sides);
- let pid = nix::unistd::Pid::from_raw(su.server_child.id() as nix::libc::pid_t);
- nix::sys::signal::kill(pid, nix::sys::signal::SIGSTOP)?;
+ let paused = su.pause_otter()?;
for side in &sides {
let w = su.w(side.window)?;
.context("conflicting drag")?;
}
- nix::sys::signal::kill(pid, nix::sys::signal::SIGCONT)?;
+ paused.resume()?;
#[derive(Debug)]
struct Got<'s> {