merged from gramsrv upstream

This commit is contained in:
onysd 2026-09-01 12:06:31 +03:00
parent 79c64ee916
commit 21a0856587
651 changed files with 54774 additions and 4590 deletions

View file

@ -0,0 +1,17 @@
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
package main
import "golang.org/x/sys/unix"
func processCPUSeconds() (float64, bool) {
var usage unix.Rusage
if err := unix.Getrusage(unix.RUSAGE_SELF, &usage); err != nil {
return 0, false
}
ns := unix.TimevalToNsec(usage.Utime) + unix.TimevalToNsec(usage.Stime)
if ns < 0 {
return 0, false
}
return float64(ns) / 1e9, true
}