Skip to main content

terminate_process

Function terminate_process 

Source
pub fn terminate_process(pid: u32, timeout: Duration) -> Result<()>
Expand description

Send SIGTERM to a process and wait for it to exit, escalating to SIGKILL if it does not terminate within timeout.

Args:

  • pid: Process ID to terminate.
  • timeout: Maximum time to wait for graceful shutdown before SIGKILL.

Usage:

terminate_process(pid, Duration::from_secs(5))?;