Expand description
Agent process helpers.
All agents run in non-interactive mode (claude -p, codex exec) under a
detached monitor that owns the process and its capture files (see
crate::monitor). The old synchronous launch/capture path
(launch_agent + capture_agent_output) was removed in 14b — the monitor
is now the single way an agent process is spawned.
Structs§
- Stray
Process - A process discovered by
discover_stray_devflow_processes: its pid, the start time recorded at discovery time, and which layer matched it.
Enums§
- Stray
Layer - Which structural layer of a DevFlow-spawned process tree
discover_stray_devflow_processesmatched a candidate against.
Constants§
- STRAY_
MIN_ AGE - The age floor
reap_stray_candidates(devflow-cli::commands) refuses to signal a candidate below. An age floor, not a classifier: it refuses every candidate younger than this in BOTH directions — a mid-execvefalse positive and a genuine stray younger than the floor are both refused, becauseprocess_agecannot tell the two apart and does not try to. - TERMINATE_
VERIFY_ POLL - Default poll interval while
terminate_and_verifywaits for its target to exit. Callers that need a different ceiling or granularity should pass their ownwait/pollrather than inventing new constants. - TERMINATE_
VERIFY_ WAIT - Default bounded wait for
terminate_and_verify’s escalation toSIGKILL. A few seconds is long enough for a well-behaved process to shut down afterSIGTERM, short enough that an unattended loop is not stalled indefinitely waiting on one that won’t.
Functions§
- agent_
running - Check whether a process with the given PID is still running.
- discover_
stray_ devflow_ processes - Census both of DevFlow’s orphan-prone process layers directly from the OS process table — the only remaining discovery surface once a project root has been deleted off disk, taking every registry entry, lock file and state file with it (999.44).
- is_
same_ process - Whether
pidis the same process instance that recordedexpected_start. - looks_
like_ devflow_ process Deprecated - Best-effort, Linux-only identity check for
devflow stop’s signalling fallback (T-23-52, PID reuse in a stale lock file): does/proc/<pid>/cmdlinename a devflow process? Reads the NUL-separated argv and reports whether any argument’s file-name component starts withdevflow. Returnsfalsewhen the file cannot be read (process exited between the liveness check and this call, non-Linux, permission denied) — the fail-closed direction. Afalsereturn means “identity could not be confirmed,” and callers must treat that as “do not signal,” never as “signal anyway.” - process_
age - How long
pidhas been running:/proc/uptime(seconds since boot) minusprocess_start_time(ticks since boot, converted to seconds via the kernel’s own reported tick rate — never a hardcoded divisor). - process_
start_ time - A process’s start time — field 22 of
/proc/<pid>/stat, in clock ticks since boot. - terminate
- Send SIGTERM to
pid— the crate’s one process-termination call, used bydevflow stop’s signalling fallback (23c). Applies exactly the same guardsagent_runningapplies, for reasons that are catastrophic here rather than merely wrong: signalling pid0would target the caller’s own process group (kill(0, sig)reaches every process in the group, including this one), and a value abovei32::MAXwould wrap negative through theas libc::pid_tcast —kill(-1, sig)sends the signal to every process the caller may signal. Returns whether the signal was delivered. - terminate_
and_ verify - Terminate
pid, escalating toSIGKILLif it has not exited withinwait, and return a verified fact about whether it is dead — never an assumption.