From 27303c919769b2594523f151ef8f62e10452913d Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 10 Oct 2016 23:27:06 -0700 Subject: more signal handling --- src/main.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 480da84..8258d60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -121,9 +121,6 @@ impl Offspring { Some(ref p) => { nix::sys::signal::kill(p.id() as i32, nix_sig).unwrap(); }, None => (), } - // TODO: abs probably isn't the best way to i32 -> u32 here - //nix::sys::signal::kill(num::abs(self.process.unwrap().id()), nix_sig); - //let pid = self.process.unwrap().id(); } } @@ -156,29 +153,32 @@ fn shepard(mut cfg: EinConfig, signal_rx: Receiver) { //// infinite select() loop over timers, signals, rpc loop { chan_select! { - timer_rx.recv() => { println!("Timer tick'd"); "TIMER" }, + timer_rx.recv() => { println!("Timer tick'd"); }, signal_rx.recv() -> sig => match sig.expect("Error with signal handler") { - // XXX: Signal::HUP => brood.iter().for_each(|o| o.signal(sig)), - Signal::INT | Signal::TERM=> { + Signal::HUP => { + for (_, o) in brood.iter_mut() { + o.signal(sig.unwrap()); + } }, + Signal::INT | Signal::TERM => { println!("Notifying children..."); - // XXX: brood.iter().for_each(|o| o.signal(sig)); + for (_, o) in brood.iter_mut() { + o.signal(sig.unwrap()); + } break; }, - _ => "Other" + _ => () } } } -/* XXX: println!("Waiting for all children to die"); - for mut o in brood.values() { + for (_, o) in brood.iter_mut() { match o.process { Some(ref mut p) => { p.wait().unwrap(); () }, None => (), } } println!("Done."); -*/ } fn print_usage(opts: Options) { -- cgit v1.2.3