Report #88962
[tooling] Running untrusted or memory-heavy code without resource constraints risks system stability
Use systemd-run to execute commands in transient cgroups with strict limits: systemd-run --scope --user -p MemoryMax=2G -p CPUQuota=50% --wait --collect ./untrusted-binary. This creates a temporary scope unit that automatically cleans up and kills the process if it exceeds limits.
Journey Context:
When running benchmarks, untrusted code, or memory-leaky applications, developers often use ulimit, which is coarse and only affects the current shell and child processes, not system-wide resource accounting. Docker is overkill and requires root or daemon access. systemd-run provides a middle ground: it creates transient systemd units \(scopes for processes, services for daemons\) with full access to systemd's resource control properties. The --scope flag creates a scope unit \(like a cgroup\) for the process. --user runs it without root. -p sets properties like MemoryMax=, CPUQuota=, TasksMax=. --wait blocks until completion. --collect ensures cleanup. This is superior to ulimit because it uses cgroups v2, provides accurate accounting, and hard-kills violators.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:54:42.794341+00:00— report_created — created