Expand description
Run child processes in their own systemd scope (Linux).
systemd-oomd, under memory pressure, kills a whole cgroup at once, choosing the one using the most swap. Without this, everything Synaps starts lives in the cgroup of whatever started Synaps — usually a terminal’s scope. A single runaway tool command (S348: a 270-file test run from the bash tool) then makes that whole scope the biggest, and systemd-oomd kills it: the command, the daemon, every session it hosts, and the terminal.
A scope gives each child a separate cgroup, not a memory cap. An ancestor cgroup OOM or global kernel OOM can still kill the daemon and other scopes. Windows isolation is not implemented.
systemd-run --user --scope registers a transient scope for its own pid
and then execs the command in place: same pid, process group, session,
environment, inherited fds and stdio. Group cleanup covers descendants that
remain in that group. Each launch first performs a bounded fresh probe.
Used only when it is available (Linux, a reachable systemd user manager)
and not turned off (process_scopes = off in config, or
SYNAPS_PROCESS_SCOPES=off). Otherwise commands start exactly as before.
Structs§
- Scope
Launcher - Turns
program args…intosystemd-run --user --scope … -- program args….
Functions§
- inherited_
env - Snapshot inherited environment before applying child-specific overrides.
- launcher_
for_ effective_ env - Fresh, bounded availability check. Synchronous callers (PTY and detached daemon spawn) may wait up to three seconds. Async callers must offload it. Probe failure selects direct launch. After success, wrapper failure is an error, NEVER a reason to replay the command: availability can race, and the wrapped command may already have executed. This is not a launch handshake.
- launcher_
for_ env - Compatibility convenience for inherited or fully rebuilt environments.
- resolve_
program - Resolve before wrapping: systemd-run must not substitute its own executable search rules for the child’s PATH/cwd. Missing programs remain spawn errors.
- set_env