Skip to main content

Module idle_gate

Module idle_gate 

Source
Expand description

Is a command that has printed nothing for the idle timeout stuck, or busy?

The idle kill exists for a command stuck waiting for input that never comes: a pager (less) in the PTY (docs/retro/RETRO_BASHWRAP_PAGER_HANG_LEAK_2026_07_14.md). But a build or test run with its output sent to a file is silent too, and it was killed in the middle of its work (seen 2026-10-17, cargo test > log). A stuck command uses no CPU and starts nothing; a busy one does. So when the timeout is reached, the gate looks at the commandโ€™s process tree twice, a probe window apart: CPU used or a new process means busy, and the timeout starts over; nothing means stuck, and the command is killed as before.

Structsยง

IdleGate ๐Ÿ”’
TreeSample ๐Ÿ”’
Each process of a tree, by key, with the CPU it had used.

Enumsยง

Verdict ๐Ÿ”’
What the gate says when the command has been silent for the idle timeout.

Constantsยง

PROBE_MAX ๐Ÿ”’
The longest probe window: how much later than the idle timeout a stuck command is killed.

Functionsยง

busy ๐Ÿ”’
Busy: a process that wasnโ€™t there before, or one that used at least 1% of a core over the window (at least 10 ms).
sample ๐Ÿ”’
tree_sample ๐Ÿ”’
root and every process descended from it.
watch ๐Ÿ”’
The pipe pathโ€™s idle watcher: every 200 ms, the time since the last byte either stream read (activity); past idle_timeout, the gate decides, and a stuck command gets idle_tx. The look at the tree is a blocking snapshot, so it runs off the async runtime.