Install any skill in seconds. Free to start, no credit card required.
Get Started Free →notque/shell-process-patterns
Safely start, supervise, and terminate shell processes: background jobs, PID capture, signals, traps, cleanup verification.
Passed 21 of 22 test cases with the skill, and 15 of 22 without it.
and 3 more in the full report
6 fixed15 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 6 test cases the skill fixed. Same model, same prompt, with and without the skill.
We need to write a shell command that finds all running process IDs for worker scripts launched as `python worker.py --queue=high`. Simple `pgrep python` returns too many unrelated processes.
| Checked | Without skill | With skill |
|---|---|---|
| Uses pgrep -fa with the full argument command string | Missed | Passed |
The instructions your model reads when the skill loads.
Start, supervise, and terminate shell processes safely -- background jobs, subshells, signal handlers, and cleanup. The dominant failure mode in this domain is silent state: a process that looks killed but still holds a port, a trap that looked fine but never fired on the child, a set -e script that kept running because || true swallowed the error. This skill picks the right pattern, implements it with the real PID (not the wrapper), and verifies the observable state afterward.
| Pattern | Use When | Key Safety Bound |
|---|---|---|
| Background start | Ad-hoc long-running child in a script or session | Redirect fd 0/1/2, capture real PID, disown if parent exits |
| Daemonization | Process must survive terminal close, become session leader | setsid + fd redirect + write PID file atomically |
| PID resolution | Need to kill / inspect the actual worker | Re-query with ss/pgrep/lsof; $! is advisory, not authoritative |
| Signal discipline | Graceful shutdown of a supervisor + children | SIGTERM first with timeout, SIGKILL as last resort, propagate to process group |
| Trap + cleanup | Script must leave no orphans, lock files, or temp dirs | trap ... EXIT + verification (file gone, port free, PID dead) |
| Strict-mode scripts | Any non-trivial bash script | set -euo pipefail with understood ` |
In scope:
&, nohup, disown, setsid, daemonization).exec semantics, process groups, subshell inheritance.EXIT vs signal traps, ordering, inheritance in subshells and functions.set -e / set -u / set -o pipefail interactions and the || escape hatch.wait semantics, reaping children, race conditions between background-start and resource readiness.Out of scope:
cron-job-auditor).condition-based-waiting).service-health-check).shell-config).| Signal | Load These Files | Why |
|---|---|---|
starting a background process, &, nohup, disown, setsid, daemonize | starting-processes.md | Launch-time patterns and fd/session rules |
capturing the child PID, $! lies, port still listening after kill | pid-resolution.md | How to get the real PID and reconcile with observed state |
trap ordering, SIGTERM/SIGKILL, subshell signal inheritance, exec | signals-and-traps.md | Signal and trap discipline |
| verifying a process is actually gone, lock file still present, port still bound | cleanup-verification.md | Kill-and-check pattern |
implementation patterns, detection commands, fix snippets, set -e + ` | ` |
test cases passed, vs 15 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.