Since Darwin / FreeBSD / OpenBSD all use process_bsd.go, remove
the duplicated "not implemented" EnvironWithContext definitions
from their custom go files.
Signed-off-by: Max Altgelt <max.altgelt@nextron-systems.com>
updated win32_Processor struct to exclude loadpercentage field.
The loadpercentage takes linearly more time as the # of sockets
increases. By default vSphere maps 1 vCPU to 1 socket, resulting in very
poor performance when getting CPU info against, saying, 40 vCPU VM
(basically 40 sockets as seen by the VM).
Prior to this commit CGO was used in OpenBSD implementation of
Process.CmdlineSliceWithContext() for parsing the "kern.proc.args"
sysctl output. It requires some pointer arithmetics and raw pointer
dereferencing.
Having CGO in the "process" module prevents it from being go vet'ted
on any platform other than OpenBSD. In order to overcome this
limitation, the sysctl output parsing was reimplemented without raw
pointer deferencing. The resulting code might be slightly slower
than the original one, but it is cleaner and safer.
Since this fix allows go vet with GOOS=openbsd to run without any
issues on all platforms, openbsd entries were also added to the "vet"
Makefile target.
Co-authored-by: Sergey Vinogradov <cbrpnk@gmail.com>
In Linux containers running in LX Branded Zones on SmartOS (potentially
other Solaris-based OSes with LX Branded Zones),
fillFromTIDStatWithContext panics as the delayacct_blkio_ticks field is
not present and thus results in an out-of-bounds slice access.
Check the slice length before and only attempt to parse the
delayacct_blkio_ticks field if there is an appropriate number of fields.
The github.com/tklauser/go-sysconf package is already a dependency used
in the cpu and v3/cpu packages to determine clock ticks using
`sysconf.Sysconf(sysconf.SC_CLK_TCK)`, see #1036. Use the same in
packages process and v3/process as well instead of hard-coding clock
ticks to 100.
This is the arm64 version of the change in
20c3ddbfe5
Before this patch:
```
dave@m1 process % GO111MODULE=off CGO_ENABLED=0 go test
--- FAIL: Test_Process_Name (0.00s)
process_test.go:312: invalid Exe
--- FAIL: Test_Process_Long_Name_With_Spaces (0.22s)
process_test.go:357: loooong name with spaces.go.exe !=
--- FAIL: Test_Process_Long_Name (0.22s)
process_test.go:402: looooooooooooooooooooong.go.exe !=
--- FAIL: Test_Username (0.00s)
process_test.go:593:
Error Trace: process_test.go:593
Error: Not equal:
expected: "dave"
actual : "root"
Diff:
--- Expected
+++ Actual
@@ -1 +1 @@
-dave
+root
Test: Test_Username
process_test.go:595: root
FAIL
exit status 1
FAIL github.com/shirou/gopsutil/process 9.955s
```
After this patch:
```
dave@m1 process % GO111MODULE=off CGO_ENABLED=0 go test
PASS
ok github.com/shirou/gopsutil/process 9.784s
dave@m1 process % GO111MODULE=off CGO_ENABLED=1 go test
PASS
ok github.com/shirou/gopsutil/process 3.180s
```
Signed-off-by: David Scott <dave@recoil.org>