Skip to content

Commit

Permalink
refactor: expose test module
Browse files Browse the repository at this point in the history
  • Loading branch information
jcnelson committed Oct 26, 2021
1 parent 88185e0 commit c5a276f
Showing 1 changed file with 3 additions and 35 deletions.
38 changes: 3 additions & 35 deletions src/deps/ctrlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,6 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

//! Cross platform handling of Ctrl-C signals.
//!
//! [HandlerRoutine]:https://msdn.microsoft.com/en-us/library/windows/desktop/ms683242.aspx
//!
//! [set_handler()](fn.set_handler.html) allows setting a handler closure which is executed on
//! `Ctrl+C`. On Unix, this corresponds to a `SIGINT` signal. On windows, `Ctrl+C` corresponds to
//! [`CTRL_C_EVENT`][HandlerRoutine] or [`CTRL_BREAK_EVENT`][HandlerRoutine].
//!
//! Setting a handler will start a new dedicated signal handling thread where we
//! execute the handler each time we receive a `Ctrl+C` signal. There can only be
//! one handler, you would typically set one at the start of your program.
//!
//! This package was further modified for stacks-blockchain to handle SIGBUS in order to gracefully
//! shut down the node in the event of a sqlite memory error.
//!
//! # Example
//! ```no_run
//! use std::sync::atomic::{AtomicBool, Ordering};
//! use std::sync::Arc;
//!
//! fn main() {
//! let running = Arc::new(AtomicBool::new(true));
//! let r = running.clone();
//!
//! ctrlc::set_handler(move || {
//! r.store(false, Ordering::SeqCst);
//! }).expect("Error setting Ctrl-C handler");
//!
//! println!("Waiting for Ctrl-C...");
//! while running.load(Ordering::SeqCst) {}
//! println!("Got it! Exiting...");
//! }
//! ```
//!
#[macro_use]

mod error;
Expand All @@ -50,6 +15,9 @@ pub use self::error::Error;
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread;

#[cfg(test)]
mod tests;

#[derive(PartialEq, Clone)]
#[repr(u8)]
pub enum SignalId {
Expand Down

0 comments on commit c5a276f

Please sign in to comment.