-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprocess_unix.go
61 lines (49 loc) · 1.14 KB
/
process_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2021 Tobias Klauser. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
package ps
import (
"path/filepath"
"time"
)
type unixProcess struct {
pid int
ppid int
uid int
gid int
command string // might be truncated, e.g. on macOS and the BSDs
executablePath string
executableArgs []string
creationTime time.Time
}
func (p *unixProcess) PID() int {
return p.pid
}
func (p *unixProcess) PPID() int {
return p.ppid
}
func (p *unixProcess) UID() int {
return p.uid
}
func (p *unixProcess) GID() int {
return p.gid
}
func (p *unixProcess) Command() string {
if p.executablePath != "" {
return filepath.Base(p.executablePath)
}
return p.command
}
func (p *unixProcess) ExecutablePath() string {
if p.executablePath != "" {
return p.executablePath
}
return p.command
}
func (p *unixProcess) ExecutableArgs() []string {
return p.executableArgs
}
func (p *unixProcess) CreationTime() time.Time {
return p.creationTime
}