https://github.com/tombuildsstuff/golang-windowsprocess
A library to support managing Windows Processes from Golang
https://github.com/tombuildsstuff/golang-windowsprocess
Last synced: over 1 year ago
JSON representation
A library to support managing Windows Processes from Golang
- Host: GitHub
- URL: https://github.com/tombuildsstuff/golang-windowsprocess
- Owner: tombuildsstuff
- License: mit
- Created: 2018-11-11T17:15:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-11T17:31:13.000Z (over 7 years ago)
- Last Synced: 2025-02-07T14:45:38.602Z (over 1 year ago)
- Language: Go
- Size: 210 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## golang-windowsprocess
This library supports managing Windows Processes from Golang.
## Why?
Job Objects are kinda like CGroups but for Windows - allowing you to throttle the CPU/Memory limits for a given pool of processes. This library makes Job Objects usable from Golang.
## Technical Notes
This is achieved by using [Job Objects](https://docs.microsoft.com/en-us/windows/desktop/ProcThread/job-objects) to assign Limits to a Process. It's planned to support both Memory and CPU limits on a Job Object - however at this time only Memory limits are supported.
Once a process has been assigned to a given Job Object - it cannot be assigned to another (this'll instead crash the process).
Job Objects can be seen using [Process Explorer](https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer):

## Example Usage
```go
jobObject, err := jobobjects.Create("Example")
if err != nil {
panic(err)
}
err = jobObject.ConfigureMemoryLimits(1200, 1200)
if err != nil {
panic(err)
}
processId := 5660
err = jobObject.AssignProcess(processId)
if err != nil {
panic(err)
}
```
## Licence
MIT