signal.rs 466 B

123456789101112131415
  1. use nix::sys::signal::{self, SigHandler, Signal};
  2. use std::sync::atomic::{AtomicBool, Ordering};
  3. pub static SIGCHILD_SIGNAL_RECEIVED: AtomicBool = AtomicBool::new(false);
  4. extern "C" fn handle_sigchld(_: libc::c_int) {
  5. SIGCHILD_SIGNAL_RECEIVED.store(true, Ordering::SeqCst);
  6. }
  7. pub fn init_signal_handler() {
  8. unsafe {
  9. signal::signal(Signal::SIGCHLD, SigHandler::Handler(handle_sigchld))
  10. .expect("Error setting SIGUSR1 handler");
  11. }
  12. }