This commit is contained in:
Ian Gulliver
2026-10-20 22:49:11 -07:00
parent 4f7d05021a
commit 99401670ee
7 changed files with 53 additions and 40 deletions
+2 -7
View File
@@ -8,13 +8,12 @@ import (
"log/slog"
"maps"
"os"
"os/exec"
"slices"
"strings"
"syscall"
"time"
"g.fc.run/ai/byre/internal/api"
"g.fc.run/ai/byre/internal/procgroup"
)
const usageTimeout = 10 * time.Second
@@ -127,11 +126,7 @@ func runUsageCommand(cmdline string) (api.Usage, error) {
}
ctx, cancel := context.WithTimeout(context.Background(), usageTimeout)
defer cancel()
cmd := exec.CommandContext(ctx, shell, "-l", "-c", cmdline)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Cancel = func() error {
return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
}
cmd := procgroup.CommandContext(ctx, shell, "-l", "-c", cmdline)
cmd.WaitDelay = time.Second
out, err := cmd.Output()
if err != nil {