MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / read_pid

Method read_pid

src/server/lifecycle.rs:44–58  ·  view source on GitHub ↗

Read PID from file

(&self)

Source from the content-addressed store, hash-verified

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>> {

Callers 3

executeMethod · 0.80
is_server_runningMethod · 0.80
test_server_lifecycleFunction · 0.80

Calls 1

pid_fileMethod · 0.80

Tested by 1

test_server_lifecycleFunction · 0.64