1个不稳定版本
0.1.0 | 2021年4月12日 |
---|
#840 in Unix API
在3个crates中使用(通过cotton)
6KB
用于保持选定Unix信号抑制的守卫类型。
use uninterruptible::Uninterruptible;
// catch terminate signals (SIGTERM, SIGQUIT, SIGINT)
let u = Uninterruptible::terminate()?;
// do work, e.g. call in sub-process
u.checkpoint()?; // fails if the process recived one of the terminate signals (e.g. CTRL-C was pressed)
drop(u); // revert to default signal handlers
更多示例,请参阅docs.rs上的模块级文档。
lib.rs
:
用于保持选定Unix信号抑制的守卫类型。
use uninterruptible::Uninterruptible;
// catch terminate signals (SIGTERM, SIGQUIT, SIGINT)
let u = Uninterruptible::terminate().unwrap();
// do work, e.g. call in sub-process
u.checkpoint().unwrap(); // fails if the process recived one of the terminate signals (e.g. CTRL-C was pressed)
drop(u); // revert to default signal handlers
依赖
~200KB