telegraf/internal/process/process_posix.go

24 lines
354 B
Go
Raw Normal View History

2020-06-05 07:09:22 +08:00
// +build !windows
package process
import (
2020-07-02 23:59:29 +08:00
"context"
2020-06-05 07:09:22 +08:00
"os/exec"
"syscall"
"time"
)
2020-07-02 23:59:29 +08:00
func gracefulStop(ctx context.Context, cmd *exec.Cmd, timeout time.Duration) {
select {
case <-time.After(timeout):
cmd.Process.Signal(syscall.SIGTERM)
case <-ctx.Done():
}
select {
case <-time.After(timeout):
cmd.Process.Kill()
case <-ctx.Done():
}
2020-06-05 07:09:22 +08:00
}