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

Merge pull request #840 from devopsext/correct_exit_code_pid_existence

[process][linux] make process.IsRunning() return nil error if process does not exist
This commit is contained in:
Lomanic 2020-02-16 19:10:08 +01:00 committed by GitHub
commit 27358e8a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,7 +83,11 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
if _, err := os.Stat(common.HostProc()); err == nil { //Means that proc filesystem exist
// Checking PID existence based on existence of /<HOST_PROC>/proc/<PID> folder
// This covers the case when running inside container with a different process namespace (by default)
_, err := os.Stat(common.HostProc(strconv.Itoa(int(pid))))
if os.IsNotExist(err) {
return false, nil
}
return err == nil, err
}