28 Commits (master)

Author SHA1 Message Date
NitroCao fcdd277935 fix: release process after os.FindProcess()
shirou bc060cc227 add SPDX License, remove old build tag, and replace import
Antoine Toulme 38b94668ea allow to pass context values to override environment variables
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>
Matthieu MOREL 1fb1e3e3e6 ci(lint): correct gci linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
mmorel-35 1e6b445a8a gofumpt
Matthieu MOREL b673968d5d
enable errorlint linter
shirou 0969c9436b delete v2 directory, move v3 to top #1078
Ville Skyttä e35ae34dce [process][solaris] process basics
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.
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
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.
Ilya Prudnikov f3598686cb Correct returned error (set to nil) in case process is not exist
Ilya Prudnikov 8dec3d81f3 Fix check pid existence when running in different process namespace (container)
Lomanic 5b15bc623c [process][posix] Fix #607 check pid existence with a signal instead of listing every pids
Reference 0d6b91e916/lockfile_unix.go
Michal Rostecki 91ac1d66ac process: Check for error objects
shirou 4c73494c78 Add WithContext functions.
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}`
Sean Chittenden 3834908232
Improve Command() handling and signal handling for launched processes.
tycho garen 22c56d292e close open files
Marco Pfatschbacher b4846b445b Add support for OpenBSD/amd64
This code is based on the FreeBSD version
and implements roughly the same feature set.
Shirou WAKAYAMA 1d461a68b6 [process]linux: porcess was not started.
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201
Shirou WAKAYAMA 9ef341037b [process]posix: update process signal document
Shirou WAKAYAMA bce9212def fix build bugs.
Shirou WAKAYAMA d21ed2b40d search path via exec.LookPath before actual invoke.
Shirou WAKAYAMA 13cd195a7e change package name.
Shirou WAKAYAMA a4671fcc2a move subdirectories. refer to issue #24