diff --git a/src/linux.rs b/src/linux.rs index e6f8987..de0151a 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -1,4 +1,9 @@ +use crate::killport::NativeProcess; + +use log::debug; +use nix::unistd::Pid; use procfs::process::FDTarget; +use std::io::Error; /// Finds the inodes associated with the specified `port`. /// @@ -70,7 +75,7 @@ fn find_target_inodes(port: u16) -> Vec { /// # Arguments /// /// * `inodes` - Target inodes -fn find_target_processes(port: u16) -> Result, Error> { +pub fn find_target_processes(port: u16) -> Result, Error> { let mut target_pids: Vec = vec![]; let inodes = find_target_inodes(port); @@ -86,9 +91,14 @@ fn find_target_processes(port: u16) -> Result, Error> { if let FDTarget::Socket(sock_inode) = fd.target { if inode == sock_inode { - debug!("Found process with PID {}", process.pid); + let name = process + .cmdline() + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))? + .join(" "); + debug!("Found process '{}' with PID {}", name, process.pid()); target_pids.push(NativeProcess { pid: Pid::from_raw(process.pid), + name: name, }); } }