bingus-blog/src/platform.rs

10 lines
321 B
Rust
Raw Normal View History

2024-06-13 23:43:03 +03:00
pub async fn sigterm() -> Result<Option<()>, std::io::Error> {
#[cfg(unix)]
let mut sigterm_handler =
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())?;
#[cfg(unix)]
return Ok(sigterm_handler.recv().await);
#[cfg(not(unix))]
std::future::pending::<None>().await
}