对os/exec
的简易封装,防止出现孤儿进程
command.ExecCommand("ebook-convert", []string{"1.txt","1.pdf"}, 30*time.Minute)
...
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
s := <-c
fmt.Println("get signal:", s)
fmt.Println("close child process...")
command.CloseChildProccess()
fmt.Println("close child process done.")
fmt.Println("exit.")
os.Exit(0)
}()
...