aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--snekbox/nsjail.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py
index b9c4fc7..b79ec9e 100644
--- a/snekbox/nsjail.py
+++ b/snekbox/nsjail.py
@@ -71,9 +71,15 @@ class NsJail:
with (mem / "memory.limit_in_bytes").open("w", encoding="utf=8") as f:
f.write(str(MEM_MAX))
- # Swap limit is specified as the sum of the memory and swap limits.
- with (mem / "memory.memsw.limit_in_bytes").open("w", encoding="utf=8") as f:
- f.write(str(MEM_MAX))
+ try:
+ # Swap limit is specified as the sum of the memory and swap limits.
+ with (mem / "memory.memsw.limit_in_bytes").open("w", encoding="utf=8") as f:
+ f.write(str(MEM_MAX))
+ except PermissionError:
+ log.info(
+ "Failed to disable memory swapping in the cgroup. "
+ "This is probably because CONFIG_MEMCG_SWAP_ENABLED is unset."
+ )
@staticmethod
def _parse_log(log_lines: Iterable[str]):