Skip to main content

kill_by_port

Function kill_by_port 

Source
pub fn kill_by_port(port: u16)
Expand description

Kill any process listening on a TCP port via lsof.

Uses -sTCP:LISTEN to restrict matches to server processes, avoiding false positives on client connections to the same port. Also filters out the calling process’s own PID as a safeguard.

Best-effort – all errors are silently ignored. This is intended as a final safety net to release the port after shutdown, not as a primary kill mechanism.

§Example

use redis_server_wrapper::process;

process::kill_by_port(6379);