Skip to main content

Module detached

Module detached 

Source
Expand description

Shell commands that outran their grace period and run on in the background.

Every shell command starts in the foreground. One that has not exited by the time lifecycle.shell_grace_secs elapses is demoted: the turn gets a work id and carries on, the command keeps running on an OS thread of its own, and its output is written to a log in the session’s records directory as it is read.

The work id is an address. [DetachedRegistry] keeps every demoted command of the session, running or finished, and the runtime-provided background-command tool (crate::background_command) reads its state, waits for it or stops it by that id. When a command finishes, the runtime also enqueues a task on this capsule with crate::origin::TaskOrigin::Completion carrying the exit code and the log’s path, unless the agent already read the exit through the tool.

Constants§

WORK_ID_PREFIX
Prefix on every work id. Distinct from tsk_/ctx_/ses_ so a reader of trace.jsonl can tell at a glance which id space a value belongs to.

Functions§

new_work_id
A fresh work id, matching ^wrk_[0-9a-f]+$.