attach-a-safer-probe-to-a-live-process
Use when a running process is misbehaving and restarting it would lose the state. Inspects it in place with non-destructive tools, capturing evidence before any intervention.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- attach-a-safer-probe-to-a-live-process
- description
- Use when a running process is misbehaving and restarting it would lose the state. Inspects it in place with non-destructive tools, capturing evidence before any intervention.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md364 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
Attach a Safer Probe to a Live Process
A hung or slow process holds the only evidence you need. Inspect its threads, stacks, and file descriptors from outside; kill nothing until you have captured and copied that evidence.
Procedure
- Identify the target precisely:
pgrep -af myserviceand confirm the pid, user, and start time so you never attach to the wrong one. - Check liveness cheaply first:
top -b -n1 -p <pid>andcat /proc/<pid>/status | grep -E 'State|Threads|VmRSS'. A state ofDpoints at I/O,Rat CPU spin,Sat a wait. - Take thread stacks non-invasively:
py-spy dump --pid <pid>(Python),jstack <pid>(JVM),gdb -p <pid> -batch -ex 'thread apply all bt'(native),pstack <pid>. Do this twice, seconds apart. - Diff the two stack samples. A line that stays in the same frame is the stuck work; a line that moves is just activity.
- Inspect open resources:
lsof -p <pid>for leaked handles andss -tnp | grep <pid>for connections inCLOSE_WAITorSYN_SENT. - Snapshot heap or metrics if the runtime supports it without pausing long:
jcmd <pid> GC.heap_info,curl localhost:<port>/metrics, or aSIGQUITthat triggers a graceful dump. - Copy every artefact out before acting: save stacks and outputs under
evidence/pid-<pid>-<time>/. - Only then choose an intervention; prefer a graceful
SIGTERMand a restart overkill -9, and never attach a write-capable debugger in production without a rollback.
Pitfalls
gdbwith a breakpoint that halts all threads in production, turning a slowdown into an outage.- Attaching with a thread-heavy sampler that itself adds latency; sample from outside the process.
- Killing with
kill -9first, which discards the core and the answer. - Assuming the newest pid is the one; supervisors restart children, so match start time.
- Reading a single stack sample and concluding "stuck in X" — one sample cannot distinguish wait from valid work.
- Leaving the process in an attached state (gdb stopped) while stepping away.
Verification
py-spy dump --pid "$(pgrep -f myservice | head -1)" > evidence/stack1.txt
sleep 3
py-spy dump --pid "$(pgrep -f myservice | head -1)" > evidence/stack2.txt
diff evidence/stack1.txt evidence/stack2.txt
# the unchanged frame across both dumps is the suspect; log the pid and timestamp with the capture
Report to the user: the pid and its state, the frame frozen across both samples, and the resource anomaly (fd or connection) if one exists.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.