mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 20:58:14 -05:00
31 lines
524 B
Go
31 lines
524 B
Go
// +build windows
|
|
|
|
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
type ProcessExitGroup struct {
|
|
cmds []*exec.Cmd
|
|
}
|
|
|
|
func NewProcessExitGroup() (ProcessExitGroup, error) {
|
|
return ProcessExitGroup{}, nil
|
|
}
|
|
|
|
func (g *ProcessExitGroup) Dispose() error {
|
|
for _, c := range g.cmds {
|
|
if err := exec.Command("taskkill", "/F", "/T", "/PID", fmt.Sprint(c.Process.Pid)).Run(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (g *ProcessExitGroup) AddProcess(cmd *exec.Cmd) error {
|
|
g.cmds = append(g.cmds, cmd)
|
|
return nil
|
|
}
|