dcg

Processes

system.processes

Protects shared machines against kills that pick their targets by pattern, parent-tree walk or broadcast: pkill, killall, kill -1, pgrep/lsof/ps-fed kill loops, xargs/find kills, remote pattern kills over ssh, interpreter broadcast kills and launchctl domain bootouts (opt-in)

  • 10blocking rules
  • 0safe patterns
  • 2Critical
  • 8High
~/.config/dcg/config.toml
[packs]
enabled = ["system.processes"]

Evaluated when a command contains kill, pkill, killall, killall5, launchctl, ssh, psutil.

Blocking rules

Each rule ID is system.processes:<name>. Use it in allowlists and [policy.rules].

  1. kill-every-process

    Critical

    kill -1 signals every process the user owns (every app, terminal and agent).

    Explanation
    A target of -1 means "every process I am allowed to signal": as root that is the whole machine, as a user it is every app, terminal, agent and daemon they own. `kill -1 <pid>` in particular is often meant as SIGHUP but reads -1 as a target. Write the signal by name and give one PID: kill -HUP <pid>
  2. launchctl-bootout-domain

    Critical

    Booting out a whole launchd domain stops every app and agent in the user session.

    Explanation
    `launchctl bootout gui/<uid>` with no service name tears down the user's entire GUI domain: every app, login item, terminal and agent in the session. Name the one service: launchctl bootout gui/$(id -u)/<label>
  3. find-exec-kill

    High

    find -exec kill signals processes chosen by a file search.

    Explanation
    The PIDs come from whatever files the search finds, and a stale pidfile names a PID that has since been reused by an unrelated process. Check each PID before signalling it: ps -o pid,ppid,pgid,command -p <pid>
  4. interpreter-signals-everything

    High

    An inline script signals every process (-1, process group 0 or 1) or kills processes found by a psutil scan.

    Explanation
    `os.kill(-1, ...)` and `process.kill(-1)` signal every process the user owns; `os.killpg(0, ...)` signals the caller's own process group (often the agent and its shell) and `os.killpg(1, ...)` init's; a `psutil.process_iter()` loop that kills its matches is a pattern kill. Keep the handle of the process you started and stop that one: proc = subprocess.Popen(...); proc.terminate()
  5. kill-computed-pids

    High

    The PIDs to kill are computed by a command substitution at run time.

    Explanation
    `kill $(pgrep ...)`, `kill $(lsof -t ...)` and `kill $(ps -o ppid= ...)` signal whatever the lookup returns at that moment: another agent's process, an app, or the init process itself (PID 1), whose children are everything the user runs. `ps -o ppid=` of a nohup'd job is PID 1. Read a PID you recorded into a variable first, then signal it: P=$(cat job.pid); kill -TERM "$P"
  6. killall

    High

    killall signals every process with a given name, including other users' work.

    Explanation
    killall matches by name across the whole machine. Other agents' builds, terminals and services share names with yours (`node`, `cargo`, `python3`), and killall5 signals every process outside the caller's session. Signal the PIDs you recorded instead: kill -TERM "$(cat job.pid)"
  7. pid-lookup-feeds-kill

    High

    A process lookup by pattern (pgrep, pidof, lsof -t, a ps listing or ps -o ppid=) feeds a kill in the same command.

    Explanation
    Looking PIDs up by pattern and killing them in one command, often in a loop or a recursive kill_tree function, kills whatever the lookup returned. When the lookup returns the parent of a nohup'd job, that parent is init or launchd (PID 1), and a tree walk from there signals every process the user runs. Look up in one command, check each PID, then signal only your own recorded PIDs in a separate command: pgrep -fl <pattern> ps -o pid,ppid,pgid,command -p <pid>
  8. pkill

    High

    pkill signals every process whose name or command line matches a pattern.

    Explanation
    A pattern kill on a shared machine also reaches other agents, terminals, desktop apps and services that happen to match. On BSD and macOS, pkill stops reading options at the first pattern, so `pkill -f 'x' -P 1` treats `-P` and `1` as two more patterns and signals every process with a 1 in its command line. Record the PID when you start a job and signal only that: cmd & echo $! > job.pid kill -TERM "$(cat job.pid)"
  9. ssh-remote-pattern-kill

    High

    The remote command kills processes by pattern on another host.

    Explanation
    Remote build and CI hosts run other people's and other agents' jobs, workers and services. A pattern kill there stops their work too. Read the PID you recorded on that host, then signal only it: ssh <host> 'P=$(cat job.pid); kill -TERM "$P"'
  10. xargs-kill

    High

    Piping a PID lookup into xargs kill signals whatever the lookup matched.

    Explanation
    `pgrep ... | xargs kill` and `lsof -t ... | xargs kill` are pattern kills: the lookup matches every process with that name or open file, not just yours. Signal the PIDs you recorded when you started your processes: kill -TERM "$(cat job.pid)"