@@ -36,8 +36,10 @@ import (
36
36
"k8s.io/klog"
37
37
)
38
38
39
+ // ProcFS provides a helper for getting container name via pid.
39
40
type ProcFS struct {}
40
41
42
+ // NewProcFS returns a ProcFS object.
41
43
func NewProcFS () ProcFSInterface {
42
44
return & ProcFS {}
43
45
}
@@ -53,7 +55,7 @@ func containerNameFromProcCgroup(content string) (string, error) {
53
55
return "" , fmt .Errorf ("could not find devices cgroup location" )
54
56
}
55
57
56
- // getFullContainerName gets the container name given the root process id of the container.
58
+ // GetFullContainerName gets the container name given the root process id of the container.
57
59
// E.g. if the devices cgroup for the container is stored in /sys/fs/cgroup/devices/docker/nginx,
58
60
// return docker/nginx. Assumes that the process is part of exactly one cgroup hierarchy.
59
61
func (pfs * ProcFS ) GetFullContainerName (pid int ) (string , error ) {
@@ -68,8 +70,8 @@ func (pfs *ProcFS) GetFullContainerName(pid int) (string, error) {
68
70
return containerNameFromProcCgroup (string (content ))
69
71
}
70
72
71
- // Find process(es) using a regular expression and send a specified
72
- // signal to each process
73
+ // PKill finds process(es) using a regular expression and send a specified
74
+ // signal to each process.
73
75
func PKill (name string , sig syscall.Signal ) error {
74
76
if len (name ) == 0 {
75
77
return fmt .Errorf ("name should not be empty" )
@@ -91,8 +93,8 @@ func PKill(name string, sig syscall.Signal) error {
91
93
return utilerrors .NewAggregate (errList )
92
94
}
93
95
94
- // Find process(es) with a specified name (regexp match)
95
- // and return their pid(s)
96
+ // PidOf finds process(es) with a specified name (regexp match)
97
+ // and return their pid(s).
96
98
func PidOf (name string ) ([]int , error ) {
97
99
if len (name ) == 0 {
98
100
return []int {}, fmt .Errorf ("name should not be empty" )
0 commit comments