rustfmt & clippy fixes

This commit is contained in:
Matt Green 2016-12-20 12:20:21 -05:00
parent 2dd2e72214
commit 171132a722
4 changed files with 22 additions and 22 deletions

View File

@ -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(" ");

View File

@ -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(),

View File

@ -20,6 +20,8 @@ mod imp {
cvar: Condvar,
}
#[allow(unknown_lints)]
#[allow(mutex_atomic)]
impl Process {
pub fn new(cmd: &str, updated_paths: Vec<PathBuf>) -> Result<Process> {
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();

View File

@ -8,7 +8,7 @@ pub enum Signal {
Terminate,
Stop,
Continue,
ChildExit
ChildExit,
}
#[cfg(unix)]
@ -32,12 +32,13 @@ pub fn install_handler<F>(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<F>(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<F>(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);