2020-06-05 07:09:22 +08:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
|
|
package process
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os/exec"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func gracefulStop(cmd *exec.Cmd, timeout time.Duration) {
|
|
|
|
|
time.AfterFunc(timeout, func() {
|
2020-06-27 04:38:07 +08:00
|
|
|
if cmd.ProcessState == nil {
|
2020-06-05 07:09:22 +08:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if !cmd.ProcessState.Exited() {
|
|
|
|
|
cmd.Process.Kill()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|