Skip to main content

force_kill

Function force_kill 

Source
pub fn force_kill(pid: u32)
Expand description

Escalating kill: SIGTERM, wait grace period, then SIGKILL process group and individual PID.

Strategy:

  1. Send SIGTERM to give the process a chance to shut down cleanly.
  2. Sleep 500ms.
  3. If still alive, SIGKILL the process group (kill -9 -$pid) to catch wrapper scripts and any children they spawned (e.g. redis-stack-server).
  4. SIGKILL the individual PID as a fallback.

Uses synchronous std::process::Command so this is safe to call from Drop impls.

ยงExample

use redis_server_wrapper::process;

process::force_kill(12345);