use std::time::Duration;
#[path = "support/orphan.rs"]
mod orphan;
fn main() {
orphan::exit_when_orphaned();
let mut args = std::env::args().skip(1);
let ms: u64 = args.next().and_then(|a| a.parse().ok()).unwrap_or(0);
if args.any(|a| a == "--ignore-sigterm") {
ignore_sigterm();
}
std::thread::sleep(Duration::from_millis(ms));
}
#[cfg(unix)]
fn ignore_sigterm() {
unsafe extern "C" {
fn signal(sig: i32, handler: usize) -> usize;
}
const SIGTERM: i32 = 15;
const SIG_IGN: usize = 1;
unsafe {
signal(SIGTERM, SIG_IGN);
}
}
#[cfg(not(unix))]
fn ignore_sigterm() {}