diff --git a/src/render/mod.rs b/src/render/mod.rs index 1c963e0..b5ea7e4 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -21,6 +21,8 @@ use std::{ process::{Command, Stdio} }; +const MEMORY_LIMIT: &str = "2G"; + const INTRO_LEN: Time = Time { seconds: 3, micros: 0 @@ -39,8 +41,18 @@ const FF_LOGO_SIZE: usize = 128; const LOGO_SIZE: usize = 96; fn cmd() -> Command { - let mut cmd = Command::new("busybox"); - cmd.arg("ash") + // we use systemd-run to limit the process memory + // I tried others like ulimit, chpst or isolate, but none worked + let mut cmd = Command::new("systemd-run"); + cmd.arg("--scope") + .arg("-q") + .arg("--expand-environment=no") + .arg("-p") + .arg(format!("MemoryMax={MEMORY_LIMIT}")) + .arg("--user"); + // we use busybox ash for having a shell that outputs commands with -x + cmd.arg("busybox") + .arg("ash") .arg("-exuo") .arg("pipefail") .arg("-c")