From 5949397c3faf8abf4faddebb57282401ef263525 Mon Sep 17 00:00:00 2001 From: maddalax Date: Mon, 23 Sep 2024 16:12:04 -0500 Subject: [PATCH] why is this happening on windows --- cli/htmgo/tasks/process/process.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/htmgo/tasks/process/process.go b/cli/htmgo/tasks/process/process.go index ab0bf51..ddd332b 100644 --- a/cli/htmgo/tasks/process/process.go +++ b/cli/htmgo/tasks/process/process.go @@ -54,10 +54,11 @@ func shouldSkipKilling(flags []RunFlag, skipFlag []RunFlag) bool { func KillAll(skipFlag ...RunFlag) { tries := 0 + removeIndexes := make([]int, 0) for { tries++ allFinished := true - for _, cmd := range commands { + for i, cmd := range commands { if cmd.cmd.Process == nil { allFinished = false @@ -65,6 +66,7 @@ func KillAll(skipFlag ...RunFlag) { args := strings.Join(cmd.cmd.Args, " ") slog.Debug("process is not running after 50 tries, breaking.", slog.String("command", args)) allFinished = true + removeIndexes = append(removeIndexes, i) break } else { time.Sleep(time.Millisecond * 50) @@ -77,6 +79,10 @@ func KillAll(skipFlag ...RunFlag) { } } + for i := len(removeIndexes) - 1; i >= 0; i-- { + commands = append(commands[:removeIndexes[i]], commands[removeIndexes[i]+1:]...) + } + for _, command := range commands { if shouldSkipKilling(command.flags, skipFlag) { continue