Skip to content

Commit

Permalink
Fix killProcessGroup (#1489)
Browse files Browse the repository at this point in the history
  • Loading branch information
directionless committed Dec 1, 2023
1 parent c5c7bd9 commit 841505b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/osquery/runtime/runtime_helpers_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ func setpgid() *syscall.SysProcAttr {
return &syscall.SysProcAttr{}
}

func killProcessGroup(cmd *exec.Cmd) error {
func killProcessGroup(origCmd *exec.Cmd) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

// some discussion here https://github.com/golang/dep/pull/857
cmd := exec.CommandContext(ctx, "taskkill", "/F", "/T", "/PID", fmt.Sprint(cmd.Process.Pid))

cmd := exec.CommandContext(ctx, "taskkill", "/F", "/T", "/PID", fmt.Sprint(origCmd.Process.Pid))
if err := cmd.Run(); err != nil {
return fmt.Errorf("creating command: %w", err)
}
Expand Down

0 comments on commit 841505b

Please sign in to comment.