process-existence-check
暂无简介
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-12
- Stars
- ★ 13
- Forks
- 2
03 SKILL.md 正文
/process-existence-check
When to Use
- Watchdog: poll whether a sandbox subprocess is still alive
- Validate PID before sending signals (SIGTERM/SIGKILL)
- Race-condition-safe check: is PID still running before cleanup?
- Detecting zombie processes (exists = true but state = Z)
Do NOT use for
- Reliable process tracking over time (use [[process-list-monitoring]])
- Cross-PID-namespace checks (must be in same namespace)
Basic check
import processExists from 'process-exists'
// Single PID
const alive = await processExists(1234)
// Multiple PIDs
const results = await processExists.all([1234, 5678, 9012])
// → Map { 1234 => true, 5678 => false, 9012 => true }
Watchdog for sandbox process
async function watchdogLoop(pid: number, intervalMs = 1000, timeoutMs = 30_000): Promise<void> {
const deadline = Date.now() + timeoutMs
while (Date.now() < deadline) {
const alive = await processExists(pid)
if (!alive) {
console.log(`[watchdog] process ${pid} exited`)
return
}
await new Promise(r => setTimeout(r, intervalMs))
}
// Timeout: kill sandbox
console.warn(`[watchdog] timeout — killing sandbox PID ${pid}`)
process.kill(pid, 'SIGKILL')
}
Safe signal send (check before kill)
# Bash: check PID exists before sending signal
safe_kill() {
local pid="$1"
local sig="${2:-SIGTERM}"
if kill -0 "$pid" 2>/dev/null; then
kill -s "$sig" "$pid"
echo "[kill] sent $sig to PID $pid"
else
echo "[kill] PID $pid not found — skipping"
fi
}
Detect zombie (exists but defunct)
is_zombie() {
local pid="$1"
local state
state=$(awk '/State:/{print $2}' "/proc/$pid/status" 2>/dev/null)
[[ "$state" == "Z" ]]
}
if processExists $PID && is_zombie $PID; then
echo "[watch] PID $PID is a zombie — waiting for parent to reap"
fi
Anti-Fake-Pass Checklist
❌ kill -0 on Linux doesn't check zombie state — process "exists" as zombie
❌ PID reuse: after check, PID may be reused by new process — not atomic
❌ processExists inside container may not see host PIDs (different PID namespace)
❌ EPERM on kill -0 → process exists but you don't have permission (still exists)
❌ Polling interval too short → CPU overhead from frequent /proc reads
04 同仓库更多 Skills
openai--sentry--sentry
Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.
ito-basket-compare
Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.
implementing-network-traffic-baselining
Build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling
detecting-evasion-techniques-in-endpoint-logs
Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.
implementing-microsegmentation-with-guardicore
Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.
ramdisk-tmpfs-patterns
暂无简介