fix shutdown logic for macos/linux (#1128)

This commit is contained in:
Mike Sawka 2024-10-24 16:07:18 -07:00 committed by GitHub
parent 2f5c4a6da7
commit 7a90754377
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,8 @@ import (
"io"
"os"
"os/exec"
"runtime"
"syscall"
"time"
"github.com/creack/pty"
@ -42,7 +44,11 @@ func (cw CmdWrap) KillGraceful(timeout time.Duration) {
if cw.Cmd.ProcessState != nil && cw.Cmd.ProcessState.Exited() {
return
}
cw.Cmd.Process.Signal(os.Interrupt)
if runtime.GOOS == "windows" {
cw.Cmd.Process.Signal(os.Interrupt)
} else {
cw.Cmd.Process.Signal(syscall.SIGTERM)
}
go func() {
time.Sleep(timeout)
if cw.Cmd.ProcessState == nil || !cw.Cmd.ProcessState.Exited() {