move sigterm functionality out

This commit is contained in:
slonkazoid 2024-06-13 23:43:03 +03:00
parent 7ad03e91bc
commit 2544184251
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM

9
src/platform.rs Normal file
View file

@ -0,0 +1,9 @@
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
}