An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Subprocess

This go package used to Kills process and all child processes it spawned in Linux or Windows.

[![GoDoc](https://godoc.org/github.com/kirill-scherba/subprocess?status.svg)](https://godoc.org/github.com/kirill-scherba/subprocess/)
[![Go Report Card](https://goreportcard.com/badge/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)