From 171132a72284cf253094b4f3b27d511577a6b11d Mon Sep 17 00:00:00 2001 From: Matt Green Date: Tue, 20 Dec 2016 12:20:21 -0500 Subject: [PATCH] rustfmt & clippy fixes --- src/cli.rs | 4 ++-- src/main.rs | 4 ++-- src/process.rs | 17 ++++++++--------- src/signal.rs | 19 ++++++++++--------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 5ff75ec..e2ef575 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -83,8 +83,8 @@ pub fn get_args() -> Args { .long("force-poll") .value_name("interval")) .arg(Arg::with_name("kill") - .help("Send SIGKILL to child processes") - .long("kill")) + .help("Send SIGKILL to child processes") + .long("kill")) .get_matches(); let cmd = values_t!(args.values_of("command"), String).unwrap().join(" "); diff --git a/src/main.rs b/src/main.rs index 7943075..90f4660 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,7 +32,7 @@ use std::path::Path; use std::sync::{Arc, RwLock}; use std::sync::mpsc::{channel, Receiver}; use std::time::Duration; -use std::path::{PathBuf}; +use std::path::PathBuf; use notification_filter::NotificationFilter; use process::Process; @@ -95,7 +95,7 @@ fn main() { } else { child.terminate(); } - }, + } Signal::Stop => child.pause(), Signal::Continue => child.resume(), Signal::ChildExit => child.reap(), diff --git a/src/process.rs b/src/process.rs index 6d98061..acd4e1d 100644 --- a/src/process.rs +++ b/src/process.rs @@ -20,6 +20,8 @@ mod imp { cvar: Condvar, } + #[allow(unknown_lints)] + #[allow(mutex_atomic)] impl Process { pub fn new(cmd: &str, updated_paths: Vec) -> Result { use nix::unistd::*; @@ -98,10 +100,10 @@ mod imp { let mut finished = true; loop { match waitpid(-self.pgid, Some(WNOHANG)) { - Ok(WaitStatus::Exited(_, _)) => finished = finished && true, + Ok(WaitStatus::Exited(_, _)) | Ok(WaitStatus::Signaled(_, _, _)) => finished = finished && true, Ok(_) => finished = false, - Err(_) => break + Err(_) => break, } } @@ -205,14 +207,11 @@ mod imp { self.terminate(); } - pub fn pause(&self) { - } + pub fn pause(&self) {} - pub fn reap(&self) { - } + pub fn reap(&self) {} - pub fn resume(&self) { - } + pub fn resume(&self) {} pub fn terminate(&self) { unsafe { @@ -318,7 +317,7 @@ mod tests { let path = file.to_path_buf(); let process = spawn(&format!("sleep 20; echo hi > {}", path.to_str().unwrap()), - vec![]); + vec![]); process.kill(); process.wait(); diff --git a/src/signal.rs b/src/signal.rs index 9161326..a26e34f 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -8,7 +8,7 @@ pub enum Signal { Terminate, Stop, Continue, - ChildExit + ChildExit, } #[cfg(unix)] @@ -32,12 +32,13 @@ pub fn install_handler(handler: F) set_handler(handler); // Indicate interest in SIGCHLD by setting a dummy handler - pub extern "C" fn sigchld_handler(_: c_int) { - } + pub extern "C" fn sigchld_handler(_: c_int) {} unsafe { - let _ = sigaction(SIGCHLD, &SigAction::new( - SigHandler::Handler(sigchld_handler), SaFlags::empty(), SigSet::empty())); + let _ = sigaction(SIGCHLD, + &SigAction::new(SigHandler::Handler(sigchld_handler), + SaFlags::empty(), + SigSet::empty())); } // Spawn a thread to catch these signals @@ -47,12 +48,11 @@ pub fn install_handler(handler: F) debug!("Received {:?}", raw_signal); let sig = match raw_signal { - SIGTERM => self::Signal::Terminate, - SIGINT => self::Signal::Terminate, + SIGTERM | SIGINT => self::Signal::Terminate, SIGTSTP => self::Signal::Stop, SIGCONT => self::Signal::Continue, SIGCHLD => self::Signal::ChildExit, - _ => unreachable!() + _ => unreachable!(), }; // Invoke closure @@ -60,7 +60,8 @@ pub fn install_handler(handler: F) // Restore default behavior for received signal and unmask it if raw_signal != SIGCHLD { - let default_action = SigAction::new(SigHandler::SigDfl, SaFlags::empty(), SigSet::empty()); + let default_action = + SigAction::new(SigHandler::SigDfl, SaFlags::empty(), SigSet::empty()); unsafe { let _ = sigaction(raw_signal, &default_action);