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

27 Commits

Author SHA1 Message Date
shirou
bc060cc227 add SPDX License, remove old build tag, and replace import 2024-05-28 22:27:17 +09:00
Antoine Toulme
38b94668ea allow to pass context values to override environment variables 2023-06-02 01:31:05 -07:00
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>
2023-04-24 15:00:01 +08:00
Matthieu MOREL
1fb1e3e3e6 ci(lint): correct gci linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2023-04-04 18:07:22 +00:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
Matthieu MOREL
b673968d5d
enable errorlint linter 2021-12-04 22:29:38 +01:00
shirou
0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
Ville Skyttä
e35ae34dce [process][solaris] process basics 2021-05-08 16:54:12 +03:00
Ville Skyttä
b7d717ba80 [process][posix] use os.Lstat for symlink check
unix.DT_LNK is not portable; per glibc docs it's a BSD extension. It is
not available e.g. in Solaris.
https://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html#index-DT_005fLNK

As a side effect, fixes incorrect equality comparison against
Stat_t.Mode, a bitmask.
2021-05-08 16:46:56 +03:00
Lomanic
0881c11a9a [process][posix] Fix #1049 check if procfs is mounted before checking if pid exists there
Benchmark before this change (process.NewProcess() calls process.PidExistsWithContext()
internally)

    go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
    goos: linux
    goarch: amd64
    pkg: github.com/shirou/gopsutil/process
    BenchmarkNewProcess-4              14722             78751 ns/op
    PASS
    ok      github.com/shirou/gopsutil/process      3.685s

Benchmark with this change applied

    go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
    goos: linux
    goarch: amd64
    pkg: github.com/shirou/gopsutil/process
    BenchmarkNewProcess-4              14835             80180 ns/op
    PASS
    ok      github.com/shirou/gopsutil/process      3.761s
2021-03-18 23:55:59 +01:00
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.
2020-10-12 18:15:29 +03:00
Ilya Prudnikov
f3598686cb Correct returned error (set to nil) in case process is not exist 2020-02-16 19:03:32 +02:00
Ilya Prudnikov
8dec3d81f3 Fix check pid existence when running in different process namespace (container) 2020-01-27 10:56:26 +02:00
Lomanic
5b15bc623c [process][posix] Fix #607 check pid existence with a signal instead of listing every pids
Reference 0d6b91e916/lockfile_unix.go
2019-07-07 16:41:13 +02:00
Michal Rostecki
91ac1d66ac process: Check for error objects 2018-06-21 16:53:53 +02:00
shirou
4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
Sean Chittenden
635b971c0e
Move from the syscall package to the golang.org/x/sys/{unix,windows} 2017-06-02 13:51:00 -07:00
Sean Chittenden
3834908232
Improve Command() handling and signal handling for launched processes. 2017-04-27 14:11:25 -07:00
tycho garen
22c56d292e close open files 2017-02-22 08:46:23 -05:00
Marco Pfatschbacher
b4846b445b Add support for OpenBSD/amd64
This code is based on the FreeBSD version
and implements roughly the same feature set.
2016-11-24 22:30:29 +01:00
Shirou WAKAYAMA
1d461a68b6 [process]linux: porcess was not started. 2016-05-20 21:13:52 +09:00
Shirou WAKAYAMA
57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201 2016-05-20 17:59:41 +09:00
Shirou WAKAYAMA
9ef341037b [process]posix: update process signal document 2016-04-20 13:29:54 +09:00
Shirou WAKAYAMA
bce9212def fix build bugs. 2016-04-01 22:22:03 +09:00
Shirou WAKAYAMA
d21ed2b40d search path via exec.LookPath before actual invoke. 2016-04-01 22:13:05 +09:00
Shirou WAKAYAMA
13cd195a7e change package name. 2014-12-30 22:09:05 +09:00
Shirou WAKAYAMA
a4671fcc2a move subdirectories. refer to issue #24 2014-11-27 10:18:15 +09:00