~jpastuszek/uninterruptible

4d79dc5dc2f56595aca3bf97dde01fee467e649d — Jakub Pastuszek a month ago 8a473b9 0.1.0
docs, LICENSE and cargo meta
4 files changed, 60 insertions(+), 2 deletions(-)

M Cargo.toml
A LICENSE
A README.md
M src/lib.rs
M Cargo.toml => Cargo.toml +8 -2
@@ 2,9 2,15 @@
name = "uninterruptible"
version = "0.1.0"
authors = ["Jakub Pastuszek <jpastuszek@protonmail.com>"]
description = "Guard type that keeps selected Unix signals suppressed"
repository = "https://git.sr.ht/~jpastuszek/uninterruptible"
homepage = "https://sr.ht/~jpastuszek/uninterruptible/"
documentation = "https://docs.rs/uninterruptible"
readme = "README.md"
keywords = ["signal", "unix"]
categories = ["command-line-interface", "os::unix-apis"]
license = "MIT"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
signal-hook = "0.3.8"

A LICENSE => LICENSE +8 -0
@@ 0,0 1,8 @@
MIT License
Copyright (c) 2018 Jakub Pastuszek

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

A README.md => README.md +26 -0
@@ 0,0 1,26 @@
[![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License]

Guard type that keeps selected Unix signals suppressed.


```rust
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
```

See module level documentation on [docs.rs] for more examples.

[crates.io]: https://crates.io/crates/uninterruptible
[Latest Version]: https://img.shields.io/crates/v/uninterruptible.svg
[Documentation]: https://docs.rs/uninterruptible/badge.svg
[docs.rs]: https://docs.rs/uninterruptible
[License]: https://img.shields.io/crates/l/uninterruptible.svg

M src/lib.rs => src/lib.rs +18 -0
@@ 1,3 1,21 @@
/*!
Guard type that keeps selected Unix signals suppressed.

```rust
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
```
*/

use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
use signal_hook::flag as signal_flag;