github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/dpipe/dpipe_unix.go (about) 1 //go:build !windows 2 // +build !windows 3 4 package dpipe 5 6 import ( 7 "context" 8 "os" 9 "os/exec" //nolint:depguard // We want no logging and no soft-context signal handling 10 "time" 11 12 "golang.org/x/sys/unix" 13 ) 14 15 func killProcess(_ context.Context, cmd *exec.Cmd) { 16 // A process is sometimes not terminated gracefully by the SIGTERM, so we give 17 // it a second to succeed and then kill it forcefully. 18 time.AfterFunc(time.Second, func() { 19 if cmd.ProcessState == nil { 20 _ = cmd.Process.Signal(unix.SIGKILL) 21 } 22 }) 23 _ = cmd.Process.Signal(os.Interrupt) 24 }