1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-08 19:29:25 +08:00

Merge pull request #1090 from MyaLongmire/windows_name_fix

simplify mutex usage
This commit is contained in:
shirou 2021-06-29 20:59:19 +09:00 committed by GitHub
commit d87e955d79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -27,7 +27,7 @@ type Process struct {
name string name string
status string status string
parent int32 parent int32
parentMutex *sync.RWMutex // for windows ppid cache parentMutex sync.RWMutex // for windows ppid cache
numCtxSwitches *NumCtxSwitchesStat numCtxSwitches *NumCtxSwitchesStat
uids []int32 uids []int32
gids []int32 gids []int32
@ -170,8 +170,7 @@ func NewProcess(pid int32) (*Process, error) {
func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) { func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) {
p := &Process{ p := &Process{
Pid: pid, Pid: pid,
parentMutex: new(sync.RWMutex),
} }
exists, err := PidExistsWithContext(ctx, pid) exists, err := PidExistsWithContext(ctx, pid)

View File

@ -27,7 +27,7 @@ type Process struct {
name string name string
status string status string
parent int32 parent int32
parentMutex *sync.RWMutex // for windows ppid cache parentMutex sync.RWMutex // for windows ppid cache
numCtxSwitches *NumCtxSwitchesStat numCtxSwitches *NumCtxSwitchesStat
uids []int32 uids []int32
gids []int32 gids []int32
@ -181,8 +181,7 @@ func NewProcess(pid int32) (*Process, error) {
func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) { func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) {
p := &Process{ p := &Process{
Pid: pid, Pid: pid,
parentMutex: new(sync.RWMutex),
} }
exists, err := PidExistsWithContext(ctx, pid) exists, err := PidExistsWithContext(ctx, pid)