Skip to content

Commit

Permalink
Handle ctrl-c signal correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kitallis committed Apr 14, 2021
1 parent 0975939 commit faba503
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/drip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sysfs_gpio::{Direction, Pin};

fn init_ctrlc_handler(running: Arc<AtomicBool>) {
ctrlc::set_handler(move || {
info!("Shutting down drip...");
info!("Shutting down the drip...");
running.store(false, Ordering::SeqCst);
})
.expect("Error setting Ctrl-C handler");
Expand All @@ -36,7 +36,7 @@ pub fn it(pin_num: u64, duration_ms: u64, period_ms: u64) -> sysfs_gpio::Result<

// run in batches to avoid over-heating the solenoid
for _ in 0..batches {
while running.load(Ordering::SeqCst) {
if running.load(Ordering::SeqCst) {
pin.set_value(0)?;
info!("Drip is ON");
sleep(Duration::from_millis(period_ms));
Expand Down

0 comments on commit faba503

Please sign in to comment.