repositorypackage
0.0.0-20240428110414-02dd86325b6e
Repository: https://github.com/mnt-ltd/command.git
Documentation: pkg.go.dev
# README
command
对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)
}()
...