Commit Graph

134 Commits (8897eba6760c3aa10bfe61285335e94317a6eb53)

Author SHA1 Message Date
Johannes Edmeier 3dc12249d3
Allow subsecont precision for process create time 6 months ago
Lomanic 76ccf0d220 [process][darwin][freebsd][linux][openbsd] Make process.Children not reliant on pgrep
pgrep -P $PID exits with status of 1 (and nothing in stdout nor stderr) both if
a process doesn't exist or it doesn't have child processes, so we don't
use it anymore on these OSes. We sort PIDs as pgrep did.

Also deprecate the ErrorNoChildren error when there are no child processes,
this is erroneous (simply check for the length of the returned slice, plus
this is not an error per se), this was only returned on linux anyway.

Fixes #1698
6 months ago
Pierre Gimalac d4ac231298
Merge branch 'master' of github.com:pgimalac/gopsutil into pgimalac/fix-proc-smaps-parsing 7 months ago
Pierre Gimalac a1f9e69b5d
fix: join path elements in case it contains spaces 7 months ago
shirou 5f158096be fix: golangci lint with max -> maxConn 7 months ago
Pierre Gimalac 33251d10ec
fix(proc): parsing of smaps path 7 months ago
shirou 6bdbf65126 [process]: Introduce DiskReadBytes on process which shows Disk IO only. 10 months ago
shirou 85f5f3a8e2 process.Uids and process.Gids are now return uint32 10 months ago
Sergey Chernomorets aace5e9d8f Groups in /proc/PID/status has type uint32.
Fix error of parser:
> error get info about worker process status 3150292: strconv.ParseInt:
> parsing "4294967293": value out of range

$ grep Groups /proc/self/status
Groups: 20001 [...] 4294967293
10 months ago
shirou bc060cc227 add SPDX License, remove old build tag, and replace import 10 months ago
shirou b10acd4894 [host]: add EnableBootTimeCache function 1 year ago
shirou 0665cafa1b chore: replace deprecated ioutil package to os and io 2 years ago
Lomanic 8b96d2e9e2 [process][posix] Realign process.Name() with python psutil to return same value on python3 scripts processes
e2c79a1 started to blindly set the process name to the full path (instead of the basename) of the cmdline exectuable
if the process name from the process comm was truncated on linux. Python psutil never did that, and this is just wrong
for python (or any executable interpreted script) where the process name is not the interpreter binary but the script
itself.

A new test to check process name value against psutil value is added here, which would hopefully catch any potential
future changes in psutil.

Reverts #542

Fixes #1485
2 years ago
Antoine Toulme 38b94668ea allow to pass context values to override environment variables 2 years ago
Matthieu MOREL 1fb1e3e3e6 ci(lint): correct gci linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2 years ago
shirou e2ae339eaf fix(process,linux): remove trailing multiple \x00 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
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
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
Matthieu MOREL 4671e649aa
enable revive linter 3 years ago
mmorel-35 1e6b445a8a gofumpt 3 years ago
Matthieu MOREL c8fd8c7b1f
enable unparam 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
Tom Barker bc4661937d Minor cleanups motivated by staticcheck warnings. 4 years ago
shirou b27be3812b [v2][process][linux] port 1112 to v2.
This port includes only code. test is not included.
4 years ago
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.
4 years ago
shirou 7ea8062810
Merge pull request #1083 from elmeyer/fix-processes-smartos
process, v3/process (Linux): fix Processes in SmartOS lx containers
4 years ago
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.
4 years ago
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.
4 years ago
shirou 9bd4bc70ae [process][linux] fix 1056 test and copy to v2 4 years ago
Jens Meißner fc074343f8
[process][linux] Fix fillFromStatusWithContext() on systems with 128 bit signal masks. 4 years ago
eriknordmark 0e13743b77 Avoid returning slice into buffer from Readfile
Signed-off-by: eriknordmark <erik@zededa.com>
4 years ago
Rishabh Arya 5b1d8ecae7 fix smap parser 4 years ago
Sergey Vinogradov 065e609cbf Refactor "process" package
* All context-less wrapping functions (the ones without WithContext
suffix) were moved into process.go since they all are the same.
* Call context is now passed to all underlying functions in
*WithContext() functions.
* All common *BSD bits were moved to process_bsd.go.
* Process.Tgid() method lacked a WithContext counterpart, so
Process.TgidWithContext() was added for uniformity.
* NewProcessWithContext() function was added since NewProcess() is
used a lot throughout the module, and there is no way to pass a
context to it.

This is a part of #761 effort.
4 years ago
shirou 7e94bb8bcd
Merge pull request #775 from TakayukiBGoto/add_additional_gids_support
[Process] Implement Groups() to get additional gids.
5 years ago
Tyler Davis 8d28f1b305 Clean up boolean condition 5 years ago
Tyler Davis 9473d01f0f Fix MemoryMaps on ARM
ARM has some tab characters in smaps instead of spaces, hence switching to strings.Fields instead of strings.Split which handles splitting on all whitespace instead of just spaces.
5 years ago
JuanLeon Lahoz 426b5148e3 Provide an estimation of Iowait metric per process 5 years ago
TakayukiB Goto a93796494b [Process] Define the Groups() only once 5 years ago
TakayukiB Goto f55f202e81 [Process] Implement Groups() to get additional gids. 6 years ago
Lomanic 547679f88e [process] Fix #760 implement IsRunning by checking process with same PID has same CreateTime as current process 6 years ago
Lomanic 36aa63bdd1 [process][linux] Propagate context internally 6 years ago
Lomanic 3eefe64948 [process] Fix #752 sort PIDS returned by process.Pids() 6 years ago
Lomanic 3465186bca [process] Fix #729 check process existence in NewProcess() 6 years ago