Antoine Toulme
b712e59295
fix more linting reports
2 years ago
Antoine Toulme
38b94668ea
allow to pass context values to override environment variables
2 years ago
cui fliter
9aa4e7a744
fix some comments
...
Signed-off-by: cui fliter <imcusg@gmail.com>
2 years ago
Eng Zer Jun
0439039205
refactor(process): compare error with `errors.Is`
...
Starting from Go 1.13, `errors.Is` is the preferable way to compare
error equality [1].
[1]: https://go.dev/blog/go1.13-errors
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2 years ago
Matthieu MOREL
1fb1e3e3e6
ci(lint): correct gci linter
...
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2 years ago
Donal Hurley
cf25de7460
Add support for getting process exe in FreeBSD
2 years ago
shirou
852f455217
fix lint
2 years ago
Eng Zer Jun
37894e9b28
test: use `T.Setenv` to set env vars in tests
...
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.
Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2 years ago
Lomanic
980cc82c08
[process][windows] Retrieve process name as basename of executable
...
We align ourself with psutil
8e4099d9f0/psutil/_pswindows.py (L749-L759)
Benchmarks show vast improvements
go test -run=BenchmarkProcessName -bench=BenchmarkProcessName ./process
goos: windows
goarch: amd64
pkg: github.com/shirou/gopsutil/v3/process
cpu: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
BenchmarkProcessName-4 180 6564033 ns/op
BenchmarkProcessNameViaExe-4 22111 51153 ns/op
PASS
ok github.com/shirou/gopsutil/v3/process 3.914s
Fixes #1368
2 years ago
Lomanic
bd4529a7cc
[process][windows] Refator a tiny bit is32BitProcess() function to be more idiomatic Go
2 years ago
Brandon Duffany
38064605a8
Fix memory leaks in darwin_cgo
2 years ago
tienthanh1993
6bc339626b
fix(process,windows): compare len(cwd) to an incorrect value
...
process/process_windows.go#L411 len(cwd) need compare to userProcParams.CurrentDirectoryPathNameLength instead of userProcParams.CurrentDirectoryPathAddress
3 years ago
Tobias Klauser
c76712b8da
host, process: delete darwin/386 code
...
The darwin/386 port was dropped in Go 1.15 and the imported version of
golang.org/x/sys also no longer supports the port. This module requires
at least Go 1.15 per go.mod, so it no longer builds on darwin/386
anyway.
3 years ago
shirou
e2ae339eaf
fix(process,linux): remove trailing multiple \x00
3 years ago
Lomanic
7501387fc1
[process][windows] Use WaitForSingleObject with a 0 delay in PidExistsWithContext
...
Reference https://stackoverflow.com/a/6493793
Fixes #1298
3 years ago
Martin Reindl
1d89235f34
host: add support for OpenBSD/armv7
3 years ago
shirou
7de7d48ef6
Merge pull request #1267 from easyops-cn/master
...
fix(process): fix OpenFilesWithContext panic problem
3 years ago
Ville Skyttä
f7e1f36418
refactor: remove unnecessary exec.LookPath calls
...
Executing the command does the lookup if needed and returns the same
error when not found, no need to do it separately.
3 years ago
paul
3cd259698f
fix(process): fix OpenFilesWithContext panic problem
3 years ago
shirou
9a667f1188
Merge pull request #1210 from mmorel-35/master
...
enable contextcheck linter
3 years ago
Rishabh Arya
0bf4299250
Add support for reading smaps_rollup
3 years ago
Sergey Kozlov
8ae037c8a1
Fix typing issues in createTimeWithContext on Freebsd/i386
...
Before change:
```
$ GOOS=freebsd GOARCH=386 go build ./process
process\process_freebsd.go:118:26: cannot use k.Start.Sec * 1000 + k.Start.Usec / 1000 (type int32) as type int64 in return argument
```
3 years ago
Matthieu MOREL
b0469a470b
Merge branch 'master' into master
3 years ago
Ville Skyttä
1e56c6f421
Spelling and grammar fixes
3 years ago
shirou
50cad0760c
Merge branch 'master' into refactor/parentwithcontext-ppidwithcontext
3 years ago
shirou
34e74aaccb
Merge pull request #1229 from PierreF/darwin-drop-callps-step2
...
Darwin drop callps step2
3 years ago
Matthieu MOREL
8ba220d241
enable contextcheck linter
3 years ago
Ville Skyttä
0306525d78
[process] implement ParentWithContext using PpidWithContext
...
Removes need for redundant ParentWithContext implementations. It had led
to it being unsupported on FreeBSD and OpenBSD even though
PpidWithContext was available for them, and different implementations
for getting the parent info used in ParentWithContext and
PpidWithContext on Darwin and Linux.
3 years ago
shirou
35fbe38505
[process][linux] Fix error handling on Children.
...
If pgrep returns error, `CallPgrepWithContext` always returns empty pids. So this Children always returns ErrorNoChildren. This PR fixes that handling.
3 years ago
Pierre Fersing
43e50e1d7d
Reduce call to ps for process package on darwin
3 years ago
Pierre Fersing
60eae48e6a
Drop test for Darwin Pids()
3 years ago
Pierre Fersing
b9b3dbe67a
Avoid ps command and use KProc on MacOS
3 years ago
shirou
dcac9d9b01
[process][windows] fix release handle
3 years ago
shirou
fdfd273cf0
Merge pull request #1218 from scop/feat/freebsd-process-start
...
[process][freebsd] implement createTimeWithContext
3 years ago
Lomanic
01cf95a92d
[process][windows] Fix #1216 fix compilation on arm/arm64
...
go build ./... with GOARCH=arm64 is otherwise failing with the following:
process\process_windows.go:412:11: undefined: readProcessMemory
process\process_windows.go:425:11: undefined: readProcessMemory
process\process_windows.go:896:32: undefined: PROCESS_MEMORY_COUNTERS
process\process_windows.go:897:10: undefined: PROCESS_MEMORY_COUNTERS
process\process_windows.go:910:50: undefined: PROCESS_MEMORY_COUNTERS
process\process_windows.go:950:21: undefined: queryPebAddress
process\process_windows.go:955:9: undefined: readProcessMemory
process\process_windows.go:961:8: undefined: readProcessMemory
process\process_windows.go:969:21: undefined: queryPebAddress
process\process_windows.go:974:9: undefined: readProcessMemory
process\process_windows.go:974:9: too many errors
3 years ago
Ville Skyttä
41e2595443
[process][freebsd] implement createTimeWithContext
3 years ago
Matthieu MOREL
4671e649aa
enable revive linter
3 years ago
mmorel-35
1e6b445a8a
gofumpt
3 years ago
mmorel-35
eb5f6203d8
gofmt
3 years ago
Matthieu MOREL
c8fd8c7b1f
enable unparam linter
3 years ago
Matthieu MOREL
b673968d5d
enable errorlint linter
3 years ago
shirou
d2e27c1712
fix dependabot v2 deletion.
3 years ago
shirou
0969c9436b
delete v2 directory, move v3 to top #1078
3 years ago
kestrelcjx
a0b6077502
chore(process): change the return value
3 years ago
kestrelcjx
3b61bb2833
chore(process): add ctx.Done() to break select
3 years ago
kestrelcjx
db054ec106
fix(process): fix the bug that the program is hung when getting the file name
3 years ago
shirou
0ce33dbe64
Merge pull request #1166 from easyops-cn/kestrel/process
...
feat(process): implement the 'OpenFilesWithContext' function of the windows system
3 years ago
kestrelcjx
5832fdfb9b
chore(process): open file in process test case
3 years ago
Max Altgelt
a4679b798b
feat: Add support for Cwd() on Windows
3 years ago
Jan De Dobbeleer
f169486407
fix: windows arm support
3 years ago