Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/tg123/jobobject

Windows JobObject utils for kill all child processes when parent process exits
https://github.com/tg123/jobobject

golang jobobject

Last synced: about 2 months ago
JSON representation

Windows JobObject utils for kill all child processes when parent process exits

Awesome Lists containing this project

README

        

# JobObject

[![](https://pkg.go.dev/badge/github.com/tg123/jobobject?status.svg)](https://pkg.go.dev/github.com/tg123/jobobject)

Windows JobObject utils for kill all child processes when parent process exits

# Exmaple

```
func main() {
e := exec.Command("notepad.exe")
e.Start()

job, err := jobobject.Create()
if err != nil {
panic(err)
}

err = job.AddProcess(e.Process)
if err != nil {
panic(err)
}

// defer job.Close() // This jobobj will be closed even if the parent process is killed
fmt.Println("ctrl + c to quit and kill notepad.exe")
time.Sleep(time.Hour * 1)
}
```