diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-10-10 23:27:06 -0700 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-10-10 23:27:06 -0700 |
commit | 27303c919769b2594523f151ef8f62e10452913d (patch) | |
tree | df487de0702bbd105e94582166b92d7292ad15a1 /src | |
parent | d89dff27be6b7317341966391ea3b3cf879d1787 (diff) | |
download | einhyrningsins-27303c919769b2594523f151ef8f62e10452913d.tar.gz einhyrningsins-27303c919769b2594523f151ef8f62e10452913d.zip |
more signal handling
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 22 |
1 files 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<Signal>) { //// 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) { |