@@ -6,6 +6,8 @@ import (
10+ "github.com/stretchr/testify/require"
11func TestBackgroundShellManager_Start(t *testing.T) {
13func TestBackgroundShellManager_Start(t *testing.T) {
@@ -248,7 +250,7 @@ func TestBackgroundShellManager_KillAll(t *testing.T) {
250 // Kill all shells
252 // Kill all shells
251− manager.KillAll()
253+ manager.KillAll(context.Background())
253 // Verify all shells are done
255 // Verify all shells are done
254 if !shell1.IsDone() {
256 if !shell1.IsDone() {
@@ -280,3 +282,25 @@ func TestBackgroundShellManager_KillAll(t *testing.T) {
286+func TestBackgroundShellManager_KillAll_Timeout(t *testing.T) {
289+ workingDir := t.TempDir()
290+ manager := newBackgroundShellManager()
292+ // Start a shell that traps signals and ignores cancellation.
293+ _, err := manager.Start(context.Background(), workingDir, nil, "trap '' TERM INT; sleep 60", "")
294+ require.NoError(t, err)
296+ // Short timeout to test the timeout path.
297+ ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
301+ manager.KillAll(ctx)
302+ elapsed := time.Since(start)
304+ // Must return promptly after timeout, not hang for 60 seconds.
305+ require.Less(t, elapsed, 2*time.Second)