fix: Send SIGTERM to child process when parent gets terminated

master v1.1.1
ptrcnull 9 months ago
parent 66aeae6166
commit ff7ac9ad75
  1. 10
      main.go

@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"os/signal"
"strings"
"syscall"
)
@ -46,6 +47,15 @@ func main() {
fmt.Printf("failed to start: %s\n", err)
}
sigs := make(chan os.Signal, 1)
go func() {
for {
_ = <-sigs
cmd.Process.Signal(syscall.SIGTERM)
}
}()
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
err = cmd.Wait()
if err != nil {
fmt.Printf("process exited with error: %s\n", err)

Loading…
Cancel
Save