Skip to content

Commit

Permalink
Implement kill delay on Windows (#552)
Browse files Browse the repository at this point in the history
* fix color output

* Implement kill delay on Windows

* Revert the change on master

* Remove extra newline
  • Loading branch information
8LWXpg authored Dec 16, 2024
1 parent 7019f7a commit 6511c41
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion runner/util_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ import (
"os/exec"
"strconv"
"strings"
"time"
)

func (e *Engine) killCmd(cmd *exec.Cmd) (pid int, err error) {
pid = cmd.Process.Pid
// https://stackoverflow.com/a/44551450
kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(pid))
return pid, kill.Run()

if e.config.Build.SendInterrupt {
if err = kill.Run(); err != nil {
return
}
time.Sleep(e.config.killDelay())
}
err = kill.Run()
// Wait releases any resources associated with the Process.
_, _ = cmd.Process.Wait()
return pid, err
}

func (e *Engine) startCmd(cmd string) (*exec.Cmd, io.ReadCloser, io.ReadCloser, error) {
Expand Down

0 comments on commit 6511c41

Please sign in to comment.