[][src]Function srvzio::utils::await_for_process_termination_signal

pub fn await_for_process_termination_signal()

Block current thread, waiting for system termination signals (i.e. SIGINT / SIGTERM).

When writing any kind of service that has to remain in execution, it will be probably necessary to find a way to block the main() thread until the process it's terminated.

This function offers an easy mechanism: until the process receives either a POSIX SIGINT, or a POSIX SIGTERM, or the equivalent on Windows, the thread calling this will block.

Just call this in your main() and add your "graceful termination logic" afterwards: it might be a bit naive, but it's simple and easy to use.