# Taking a consistent snapshot [Русский](Consistent-capture-ru.md) · [Wiki home](Home.md) While nano is handling a keystroke, it can change its text and undo records, then write output that tmux will consume. Reading these processes in sequence while they run could combine a new editor buffer with an old screen. arch-m2m captures the supported application group at a common stop, then also checks whether each program can resume from the state the adapter understands. ```text controller application cgroup |---- lock instance, check tasks --------->| |---- request freeze --------------------->| |<--- cgroup.events: frozen 1 -------------| |---- read application + kernel state ---->| tasks paused |---- request thaw ----------------------->| |<--- cgroup.events: frozen 0 -------------| ``` A cgroup is a kernel grouping of tasks. In cgroup v2 a write of `1` to `cgroup.freeze` requests a freeze. Its completion is asynchronous. The controller waits for `frozen 1` in `cgroup.events` and operates from outside the application group, where it can still run its checks and request a thaw. [Linux cgroup v2](https://docs.kernel.org/admin-guide/cgroup-v2.html) ## What is checked - **Before the freeze.** A managed client holds a shared instance lock. Semantic capture needs the exclusive lock and checks the expected application membership. It refuses a group already frozen by another operation. The process checks are described in [Process identity and namespaces](Process-identity.md). - **At the stop.** Adapters inspect the frozen applications using the registered layouts. A waiting shell can be at a primary prompt with partially typed input, or waiting for an admitted nano child. Pending terminal data, an active script or an unrecognized foreground job can make the checkpoint ambiguous. - **For nano.** Waiting for a byte does not uniquely identify an editor state. For instance, after Alt+V, nano awaits a character with different semantics from ordinary editing. The semantic exporter briefly trace-stops the editor with `ptrace()`, reads registers, requests the group freeze, detaches, then checks the blocked input and expected call frames. This evidence belongs to that capture. The portable bundle records the buffer and editor objects. [ptrace(2)](https://man7.org/linux/man-pages/man2/ptrace.2.html) - **Before returning.** The exporter checks the consistency of captured state. Recovery and cleanup paths release the freeze requested by the operation after rechecking the group identity. A detached source can continue working after capture. Changes made later belong to a subsequent snapshot. The freezer covers members of the application cgroup. An unrelated process can still write a shared file, and a remote server can still change its state. File checks and limits on external descriptors bound what this profile can promise. The relevant source modules are `src/semantic/ownership.py`, `src/semantic/linux.py` and `src/semantic/resources.py`.