summaryrefslogtreecommitdiff
path: root/sd_login/systemd_cgroup.go
diff options
context:
space:
mode:
Diffstat (limited to 'sd_login/systemd_cgroup.go')
-rw-r--r--sd_login/systemd_cgroup.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/sd_login/systemd_cgroup.go b/sd_login/systemd_cgroup.go
index 29ff38f..6c64525 100644
--- a/sd_login/systemd_cgroup.go
+++ b/sd_login/systemd_cgroup.go
@@ -54,7 +54,7 @@ func cgVersion() uint {
return cgVersion_cache
}
-// getCgroup returns the cgroup path of the process, relative to the
+// GetCgroup returns the cgroup path of the process, relative to the
// root of the cgroup hierarchy.
//
// In cgroup v2, there is a only one cgroup hierarchy, so the behavior
@@ -78,7 +78,7 @@ func cgVersion() uint {
// come in if both "name=systemd" and "name=elogind" controllers
// exist. Systemd and elogind cannot be used together, so this isn't
// a concern.
-func (pid ProcessID) getCgroup() (_Cgroup, error) {
+func (pid ProcessID) GetCgroup() (string, error) {
cgVer := cgVersion()
cgroupFilename := fmt.Sprintf("/proc/%d/cgroup", pid)
@@ -108,7 +108,7 @@ func (pid ProcessID) getCgroup() (_Cgroup, error) {
hierarchy := parts[0]
controllers := parts[1]
- path := _Cgroup(parts[2])
+ path := parts[2]
switch cgVer {
case 1:
@@ -127,6 +127,11 @@ func (pid ProcessID) getCgroup() (_Cgroup, error) {
return "", unix.ENODATA
}
+func (pid ProcessID) getCgroup() (_Cgroup, error) {
+ cgroup, err := pid.GetCgroup()
+ return _Cgroup(cgroup), err
+}
+
// cgGetRootPath determines the cgroup that all other cgroups belong
// to. The common case is just "/", but it could be something else if
// we are inside of a container, but have a view of the entier cgroup