AI model deployment mostly runs on Python processes, and reaching for kill -9 to close out a hang carries a high cost. This week's Juejin engineering note reminds us: check the state first, then decide how to terminate.

What this is

The author wrote a roughly 30-line Python program that spawns three child processes simultaneously: a reader blocked on a pipe (shows S state), a worker in a dead-loop computation (R state continuously consuming CPU), and a child left unreaped by its parent after fork (briefly appearing as a Z zombie). Combined with ps, /proc/<pid>/status, and wchan, the demonstration shows how to diagnose root causes from the STAT column: R points to scheduling and compute hotspots, S to I/O and locks, D to underlying device issues, and Z to a parent that hasn't called the wait family for cleanup.

Industry view

This methodology isn't new—the ps manual and Linux Performance Tuning both cover it. What's genuinely worth bookmarking is the "reproducibility": a single local code snippet creates three typical states on demand, removing the need to rely solely on production samples during incident response. The limitations are also clear—wchan can display as "-" or a raw address across different kernels and distros and cannot be taken as direct evidence; in production, never sweep with a broad pkill -f, which easily kills same-named services by accident. One level deeper, AI framework hangs frequently occur at the intersection of GPU waits, the Python GIL, and data loaders, so reading user-space process state alone is often insufficient.

Impact on regular people

For enterprise IT: tech stacks running model inference, message queues, or scheduled tasks—most problems ultimately land in one of these states: R/S/D/Z/I. Teams should fold ps -L and pidstat into their on-call playbooks.For individual careers: AI engineers are typically trained to "tune models," but production hangs are rarely model issues—they're processes stuck in system calls or I/O. Debugging capability is severely undervalued.For the consumer market: the impact is indirect; users don't feel it directly, but behind every "service briefly unavailable" there may be the hidden cost of a brute-force kill -9.