Snakepit.ProcessKiller (Snakepit v0.6.10)

View Source

Robust OS process management using Erlang primitives. No shell commands, pure Erlang/Elixir.

This module provides POSIX-compliant process management that works across Linux, macOS, and BSD systems without relying on shell-specific features like pkill.

Summary

Functions

Finds all Python processes on the system. Returns a list of OS PIDs.

Gets the command line of a process. POSIX-compliant using /proc on Linux, ps on macOS/BSD.

Kills all processes matching a run ID. Pure Erlang implementation, no pkill.

Kills a process by PID using proper Erlang signals.

Kills a process with escalation: SIGTERM -> wait -> SIGKILL

Checks if a process is alive. Uses kill -0 (signal 0) which doesn't kill but checks existence.

Functions

find_python_processes()

Finds all Python processes on the system. Returns a list of OS PIDs.

get_process_command(os_pid)

Gets the command line of a process. POSIX-compliant using /proc on Linux, ps on macOS/BSD.

kill_by_run_id(run_id)

Kills all processes matching a run ID. Pure Erlang implementation, no pkill.

kill_process(os_pid, signal \\ :sigterm)

Kills a process by PID using proper Erlang signals.

Parameters

  • os_pid: OS process ID (integer)
  • signal: :sigterm | :sigkill | :sighup

Returns

  • :ok if kill succeeded
  • {:error, reason} if kill failed

kill_with_escalation(os_pid, timeout_ms \\ 2000)

Kills a process with escalation: SIGTERM -> wait -> SIGKILL

process_alive?(os_pid)

Checks if a process is alive. Uses kill -0 (signal 0) which doesn't kill but checks existence.