1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

429 Commits

Author SHA1 Message Date
Matthieu MOREL
b0469a470b
Merge branch 'master' into master 2022-02-01 19:28:26 +01:00
Ville Skyttä
1e56c6f421 Spelling and grammar fixes 2022-01-30 22:48:09 +02:00
shirou
50cad0760c
Merge branch 'master' into refactor/parentwithcontext-ppidwithcontext 2022-01-30 10:47:00 +09:00
shirou
34e74aaccb
Merge pull request #1229 from PierreF/darwin-drop-callps-step2
Darwin drop callps step2
2022-01-30 10:38:10 +09:00
Matthieu MOREL
8ba220d241 enable contextcheck linter 2022-01-24 09:26:50 +01:00
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.
2022-01-22 18:27:52 +02:00
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.
2022-01-15 14:09:57 +00:00
Pierre Fersing
43e50e1d7d Reduce call to ps for process package on darwin 2022-01-14 09:41:54 +01:00
Pierre Fersing
60eae48e6a Drop test for Darwin Pids() 2022-01-13 13:27:05 +01:00
Pierre Fersing
b9b3dbe67a Avoid ps command and use KProc on MacOS 2022-01-13 11:57:04 +01:00
shirou
dcac9d9b01 [process][windows] fix release handle 2022-01-06 22:16:57 +09:00
shirou
fdfd273cf0
Merge pull request #1218 from scop/feat/freebsd-process-start
[process][freebsd] implement createTimeWithContext
2022-01-06 22:04:54 +09:00
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
2022-01-05 01:09:23 +01:00
Ville Skyttä
41e2595443 [process][freebsd] implement createTimeWithContext 2022-01-05 01:20:20 +02:00
Matthieu MOREL
4671e649aa
enable revive linter 2021-12-22 23:49:50 +01:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
mmorel-35
eb5f6203d8 gofmt 2021-12-22 21:46:33 +00:00
Matthieu MOREL
c8fd8c7b1f
enable unparam linter 2021-12-22 19:53:14 +01:00
Matthieu MOREL
b673968d5d
enable errorlint linter 2021-12-04 22:29:38 +01:00
shirou
d2e27c1712 fix dependabot v2 deletion. 2021-12-01 00:12:55 +00:00
shirou
0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
kestrelcjx
a0b6077502 chore(process): change the return value 2021-11-20 21:25:08 +08:00
kestrelcjx
3b61bb2833 chore(process): add ctx.Done() to break select 2021-11-20 21:12:31 +08:00
kestrelcjx
db054ec106 fix(process): fix the bug that the program is hung when getting the file name 2021-11-20 17:39:22 +08:00
shirou
0ce33dbe64
Merge pull request #1166 from easyops-cn/kestrel/process
feat(process): implement the 'OpenFilesWithContext' function of the windows system
2021-11-13 20:51:25 +09:00
kestrelcjx
5832fdfb9b chore(process): open file in process test case 2021-10-29 20:20:23 +08:00
Max Altgelt
a4679b798b
feat: Add support for Cwd() on Windows 2021-10-27 09:55:26 +02:00
Jan De Dobbeleer
f169486407
fix: windows arm support 2021-10-20 13:49:30 +02:00
shirou
703175c3fb [v2][process][windows] fix Kill causes DuplicateHandle error 2021-10-17 09:59:20 +00:00
kestrel
3dabe50107 feat(process): implement the 'OpenFilesWithContext' function of the windows system 2021-10-11 05:30:29 +08:00
shirou
7be7e7807f [process] extend maxElapsedTime on process_test 2021-09-30 07:47:05 +00:00
shirou
0d0659af18
Merge pull request #1122 from secDre4mer/master
chore: Drop PROCESS_QUERY_INFORMATION support
2021-08-28 12:33:15 +09:00
Tom Barker
9248140c98 Wait for server connection to be established before checking
connections.
2021-08-23 16:30:51 -04:00
Tom Barker
bc4661937d Minor cleanups motivated by staticcheck warnings. 2021-08-19 10:43:06 -04:00
Tom Barker
5ce887df8f Make sure that Test_AllProcesses_cmdLine doesn't ignore failures. 2021-08-19 10:43:06 -04:00
Tom Barker
34cdfa258b Test_Connections currently fails intermittently on Linux (and maybe
other OSs), and fails consistently if run with `go test -times=N`

On inspection, Go closes TCP connections when they go out of scope and
are garbage collected. I've re-written Test_Connections() to explicitly
close connectections once the test has finished. This has the other
benefit of closing gracefully, which means the -times argument should
work.

I've also removed the t.Skip() calls inside goroutines as they are
unsupported.
2021-08-19 10:40:27 -04:00
Max Altgelt
d07af877ef
chore: Drop PROCESS_QUERY_INFORMATION support
PROCESS_QUERY_INFORMATION was used for compatibility reasons with
Windows XP / Server 2003. Both are no longer supported in Golang
and haven't been for a while (since Go 1.11). It should be safe
to drop this flag. PROCESS_QUERY_LIMITED_INFORMATION supports
PPL process such as LSASS, which are not queryable without this
change.
2021-08-19 15:41:50 +02:00
shirou
b27be3812b [v2][process][linux] port 1112 to v2.
This port includes only code. test is not included.
2021-08-14 08:22:57 +00:00
Max Altgelt
9ad6c64727
fix: Remove superfluous EnvironWithContext definitions
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>
2021-07-19 09:22:20 +02:00
Max Altgelt
5f61473ffd
fix: Correct UNICODE_STRING64 definition
Correct the UNICODE_STRING64 definition. The length is only
16 bits, followed by 16 bit max length and 32 bit padding.
2021-07-19 07:34:42 +02:00
Max Altgelt
73fee847e6
chore: add tests
Add simple tests to verify that environment variables are read.
2021-07-13 16:38:49 +02:00
Max Altgelt
b02b92e16b
feat: Add support for environment variable read
Add support (for Linux and Windows for now) for reading the
environment variables of a process, with a similar syntax to
os.Environ().
For Windows, this includes some refactoring for clean access to the
RTL_USER_PROCESS_PARAMETERS structure which points to the command
line and the environment variables.
2021-07-13 15:11:29 +02:00
shirou
d87e955d79
Merge pull request #1090 from MyaLongmire/windows_name_fix
simplify mutex usage
2021-06-29 20:59:19 +09:00
shirou
daec167ba2
Merge pull request #1087 from ivandeex/openbsd-process-nocgo
process, v3/process (openbsd):  remove remaining CGO bits from CmdlineSliceWithContext
2021-06-28 22:38:03 +09:00
Mya
cb512c8500 simplify mutex usage 2021-06-24 15:18:00 -07:00
shirou
7ea8062810
Merge pull request #1083 from elmeyer/fix-processes-smartos
process, v3/process (Linux): fix Processes in SmartOS lx containers
2021-06-20 00:30:09 +09:00
Ivan Andreev
d6e0932b96 Remove CGO bits from process_openbsd.go (also v3)
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>
2021-06-11 03:38:46 +03:00
Lars Meyer
e42c52cb35 [process][linux] add test for missing iotime in SmartOS lx containers 2021-06-04 10:38:28 +02:00
Lars Meyer
0ab3954dc4 [process][linux] fix Processes in SmartOS lx containers
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.
2021-06-04 10:15:21 +02:00
Tobias Klauser
611c8b576e process, v3/process: use SC_CLK_TCK sysconf value instead of hard-coding clock ticks
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.
2021-06-02 14:11:11 +02:00