diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index 2baa12106..15c7e8ed4 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -80,20 +80,18 @@ pub struct Alarm { } impl Alarm { - pub fn with_interval(interval: Duration) -> Alarm { + pub fn with_interval(interval: Duration) -> Self { let trigger = Arc::new(AtomicBool::default()); let weak_trigger = Arc::downgrade(&trigger); - std::thread::spawn(move || loop { - sleep(interval); - if let Some(trigger) = weak_trigger.upgrade() { + std::thread::spawn(move || { + while let Some(trigger) = weak_trigger.upgrade() { + sleep(interval); trigger.store(true, Relaxed); - } else { - break; } }); - Alarm { interval, trigger } + Self { interval, trigger } } pub fn is_triggered(&self) -> bool {