diff options
author | Paul Hummer <paul@eventuallyanyway.com> | 2018-06-05 09:55:20 -0600 |
---|---|---|
committer | Paul Hummer <paul@eventuallyanyway.com> | 2018-06-05 09:55:20 -0600 |
commit | 2f418cff774a293457df66c0f67dc930c3abfc9c (patch) | |
tree | 5e20de127b65292006c3ab38e20d4ab8febf0178 /src | |
parent | 3cff7fcbbd419dfe1d4c15140e8e02d016926359 (diff) |
♬ : Joshua Radin / No Envy No Fear (Live)
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -50,23 +50,20 @@ impl Pidlock { } fn check_stale(&self) { - match fs::OpenOptions::new().read(true).open(self.path.clone()) { - Ok(mut file) => { - let mut contents = String::new(); - file.read_to_string(&mut contents).unwrap(); - - match contents.trim().parse::<i32>() { - Ok(pid) => { - if !process_exists(pid) { - warn!("Removing stale pid file at {}", self.path); - fs::remove_file(&self.path).unwrap(); - } + if let Ok(mut file) = fs::OpenOptions::new().read(true).open(self.path.clone()) { + let mut contents = String::new(); + file.read_to_string(&mut contents).unwrap(); + + match contents.trim().parse::<i32>() { + Ok(pid) => { + if !process_exists(pid) { + warn!("Removing stale pid file at {}", self.path); + fs::remove_file(&self.path).unwrap(); } - Err(_) => fs::remove_file(&self.path).unwrap(), } + Err(_) => fs::remove_file(&self.path).unwrap(), } - Err(_) => {} - }; + } } pub fn acquire(&mut self) -> PidlockResult { |