Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mnt-ltd/command
https://github.com/mnt-ltd/command
Last synced: about 8 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/mnt-ltd/command
- Owner: mnt-ltd
- License: apache-2.0
- Created: 2024-03-06T13:07:30.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-04-28T11:05:52.000Z (8 months ago)
- Last Synced: 2024-11-09T03:26:25.400Z (about 2 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# command
对`os/exec`的简易封装,防止出现`孤儿进程`
## 使用示例
### 执行相应指令
```go
command.ExecCommand("ebook-convert", []string{"1.txt","1.pdf"}, 30*time.Minute)
```### 关闭可能存在的孤儿进程
```go
...
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)
}()
...
```