kill

Function kill 

Source
pub fn kill(pid: u32) -> Result<(), String>
Expand description

Terminates a process by its process ID.

This function attempts to terminate the specified process using Windows API. It returns a Result indicating success or failure with detailed error message.

§Safety

This function is unsafe because it works with raw Windows handles.

§Arguments

  • pid - The process ID to terminate

§Returns

  • Ok(()) - Process was successfully terminated
  • Err(String) - Error message describing the failure

§Examples

    match tasklist::kill(1234) {
        Ok(()) => println!("Process terminated successfully"),
        Err(e) => eprintln!("Failed to terminate process: {}", e),
}