Read PID from file
(&self)
| 42 | |
| 43 | /// Read PID from file |
| 44 | pub fn read_pid(&self) -> Option<u32> { |
| 45 | let pid_file = self.tsk_env.pid_file(); |
| 46 | |
| 47 | let mut file = match fs::File::open(&pid_file) { |
| 48 | Ok(f) => f, |
| 49 | Err(_) => return None, |
| 50 | }; |
| 51 | |
| 52 | let mut contents = String::new(); |
| 53 | if file.read_to_string(&mut contents).is_err() { |
| 54 | return None; |
| 55 | } |
| 56 | |
| 57 | contents.trim().parse().ok() |
| 58 | } |
| 59 | |
| 60 | /// Remove PID file |
| 61 | pub fn remove_pid(&self) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { |