#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
use std::io::Result;
use std::time::Duration;
#[cfg(target_os = "linux")]
#[path = "./linux.rs"]
mod imp;
#[cfg(any(
target_os = "freebsd",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
))]
#[path = "./bsd.rs"]
mod imp;
#[cfg(windows)]
#[path = "./windows.rs"]
mod imp;
#[cfg(test)]
mod tests;
#[derive(Debug)]
#[must_use = "`WaitHandle` does nothing unless you `wait` it"]
pub struct WaitHandle(imp::WaitHandle);
impl WaitHandle {
pub fn open(pid: i32) -> Result<Self> {
Ok(Self(imp::open(pid)?))
}
#[allow(clippy::missing_panics_doc)]
pub fn wait(&mut self) -> Result<()> {
imp::wait(&mut self.0, None)?.expect("no timeout");
Ok(())
}
pub fn wait_timeout(&mut self, timeout: Duration) -> Result<Option<()>> {
imp::wait(&mut self.0, Some(timeout))
}
}