https://github.com/kirill-scherba/subprocess
Kill process and all child processes it spawned in Linux or Windows
https://github.com/kirill-scherba/subprocess
child-processes go golang kill killall linux process subprocess windows
Last synced: 11 months ago
JSON representation
Kill process and all child processes it spawned in Linux or Windows
- Host: GitHub
- URL: https://github.com/kirill-scherba/subprocess
- Owner: kirill-scherba
- License: bsd-3-clause
- Created: 2023-04-25T07:18:58.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-25T08:20:28.000Z (almost 3 years ago)
- Last Synced: 2025-02-12T08:58:53.709Z (about 1 year ago)
- Topics: child-processes, go, golang, kill, killall, linux, process, subprocess, windows
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Subprocess
This go package used to Kills process and all child processes it spawned in Linux or Windows.
[](https://godoc.org/github.com/kirill-scherba/subprocess/)
[](https://goreportcard.com/report/github.com/kirill-scherba/subprocess)
The main idea behind creating this package is that the Windows code part is
very large and it is not practical to copy this code to every project.
## Usage example
```go
package main
import "kirill-scherba/subprocess"
func main() {
// Create some process, f.e. run exec.Run() function which execute buch
// file with subprocesses
//
// var cmd *exec.Cmd
// var err error
// cmd, err = exec.Run("executable_name", "parameter")
// ...
// Use the KillProcessTree function when you want stop execution started
// process and all its child process.
//
// Kill the process and all its children
err = subprocess.KillProcessTree(cmd.Process.Pid)
if err != nil {
return
}
// ...
}
```
## Licence
[BSD](LICENSE)