From 6204f1247cdc07fc9eed97197b901d2cf9540c74 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 25 Sep 2026 20:46:13 +0200 Subject: [PATCH] Sandbox-Test: die Prozessgrenze zaehlt nur die Sandbox (#654) Co-Authored-By: Claude Opus 5.5 --- .../Sandbox/SandboxEscapeTests.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/ClawdDotNet.Core.Tests/Sandbox/SandboxEscapeTests.cs b/tests/ClawdDotNet.Core.Tests/Sandbox/SandboxEscapeTests.cs index d70ba60..2307368 100644 --- a/tests/ClawdDotNet.Core.Tests/Sandbox/SandboxEscapeTests.cs +++ b/tests/ClawdDotNet.Core.Tests/Sandbox/SandboxEscapeTests.cs @@ -195,6 +195,17 @@ public sealed class SandboxEscapeTests : IDisposable (result.StandardError + result.StandardOutput).ShouldMatch("(?i)(fork|resource temporarily unavailable|cannot)"); } + [SandboxFact] + public async Task The_limit_counts_the_sandbox_not_the_instances_threads() + { + // The instance itself runs hundreds of threads under the same user. Were those counted, + // the first fork would fail; five of ten must go. + var result = await Sh("i=0; while [ $i -lt 5 ]; do sleep 1 & i=$((i+1)); done; wait; echo started $i", + new SandboxLimits { Timeout = TimeSpan.FromSeconds(20), MaxProcesses = 10 }); + + result.StandardOutput.ShouldContain("started 5", customMessage: result.StandardError); + } + [SandboxFact] public async Task The_programs_exit_code_comes_back() => (await Sh("exit 3")).ExitCode.ShouldBe(3);