Commit Graph

54 Commits (842e4da755edf2df61b3adea0f65aecf15b7f156)

Author SHA1 Message Date
cui fliter 9aa4e7a744 fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2 years ago
Ville Skyttä 1e56c6f421 Spelling and grammar fixes 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
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
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
Mya cb512c8500 simplify mutex usage 4 years ago
Paweł Zuzelski 17c03b3b2d Clarify the godoc of the Children function.
The previous godoc string was slightly confusing and only described information that can be deduced from the function signature.
4 years ago
shirou a9a6146c93 [process] fix MemoryInfo comment. remove Swap
fixes #1012
4 years ago
AtakanColak 13602a3824 fix ppid cache race condition #964 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
ninedraft 34df4904f6 use cancelable sleep in cpu.PercentWithContext and process.Process.PercentWithContext 5 years ago
shirou 7e94bb8bcd
Merge pull request #775 from TakayukiBGoto/add_additional_gids_support
[Process] Implement Groups() to get additional gids.
5 years ago
Lomanic e34a731c69 [process] Fix #773 remove data race in NewProcess
Reproduction case https://github.com/shirou/gopsutil/issues/773#issuecomment-554723678
5 years ago
TakayukiB Goto a93796494b [Process] Define the Groups() only once 5 years ago
Laurent Sesques b3cfb9abc3 Revert "[process] Fix #599 cap percent values returned by *Percent() between 0 and 100"
This reverts commit f4e23559a2.
Fixes #755
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 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
shirou 3ad4fbbb0c
Merge pull request #715 from Lomanic/issue599process
[process] Fix #599 cap percent values returned by *Percent() between 0 and 100
6 years ago
Lomanic f4e23559a2 [process] Fix #599 cap percent values returned by *Percent() between 0 and 100 6 years ago
Lomanic 5b15bc623c [process][posix] Fix #607 check pid existence with a signal instead of listing every pids
Reference 0d6b91e916/lockfile_unix.go
6 years ago
shirou 457f04671d [process] move PageFaultsStat to process.go 6 years ago
shirou 98c84ed30a [process]: move HWM to MemoryInfo
at least FreeBSD and Darwin has HWM.
6 years ago
Lomanic 878e0a701b Fix #596 Implement process.Background and process.Foreground functions 6 years ago
shirou 26a4a2f995 [process]: move ErrorNoChildren to platform independent. 7 years ago
Laurie Clark-Michalek 413cb32b6c Use static initialisation for invoke instances, instead of init funcs
The order of init function execution is dependant on the order that the
source files are passed to the compiler. This causes issues when
building under other build systems, such as bazel or buck, as they are
not guarenteed to maintain the same file order as the default go tool.
7 years ago
shirou cd61c36c4f
Merge branch 'master' into feature/add_context_support 7 years ago
Nick Kirsch 482ca3af6d Parses the tgid field, which is the thread group id (aka user-space process id) on Linux. Returns error on other platforms. 7 years ago
shirou 4c73494c78 Add WithContext functions. 7 years ago
Leonid Podolny 4269f19b1b process.go: reformat whitespaces to keep gofmt happy 8 years ago
Kemal Hadimli 826e63acbc Never divide by zero 8 years ago
Kemal Hadimli a3144a6850 Remove parens 8 years ago
Kemal Hadimli 696e1e0123 Fix NaN percentage if process was created too soon 8 years ago
shirou a452de7c73 Merge pull request #346 from phemmer/rlimit-current
add current values to rlimit retrieval
8 years ago
Aditya Choudhary (c) 533161c2ed added funtion for calculation of CPU usage percentage of a process 8 years ago
Patrick Hemmer 60c32eb847 add current values to rlimit retrieval 8 years ago
Vyacheslav Kuznetsov a35c32b028 Commented the constants origin. 8 years ago
Vyacheslav Kuznetsov 4de4e17f06 Added limit constants. Implemented function to parse process limits from /proc. 8 years ago
Shannon Wynter c903f14189 Remove the requirement to use lsof by using the information provided in status to get the parent pid 9 years ago
Shirou WAKAYAMA 4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase. 9 years ago
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters 9 years ago
Shirou WAKAYAMA 627d2a9871 [process]: fix CPU_Percent always 0 if duration > 0 (#172) 9 years ago
Johan Walles 70444b571b process: Implement platform independent MemoryPercent()
It calls mem.VirtualMemory() and process.MemoryInfo(), so on the platforms where
those work MemoryPercent() will as well.

Tested on Darwin.
9 years ago
Johan Walles ebaa641e63 Make a public function for computing total CPU time
This function used to be a private part of process.go.

Since I needed that functionality however I think it's better to make it public
than for me to copy it into my own code.

As a side effect of this change, I also fixed a bug in the function where Stolen
was not part of the sum. Having the function close to the CPUTimesStat
declaration will make problems like this less likely to re-occur in the future.
9 years ago
Cameron Sparr 6688f35cd1 Optimize per-process stats calculation 9 years ago
Daniel Theophanes 0af895258e common: rename package common to internal/common. Add ENV helper funcs.
Package common wasn't used for public functions. Place it in an
internal directory to prevent other packages from using.

Remove the distributed references to "HOST_PROC" and "HOST_SYS"
consts and combine into a common function. This also helps so that
if a env var is defined with a trailing slash all will continue to
work as expected.

Fixes #100
10 years ago
Shirou WAKAYAMA fc513b6f9a proces[darwin]: change exec.Command to interface to enable mocking.
Add common.invoker interface to mock exec.Command. common.FakeInvoker returns
expected file if exists instead of invoke exec.Command.
Currenly, mocking is enabled only process.Pids(). I will expand to other funcs incrementally.
10 years ago